Hi,
I'm trying to get a feeling for when things should be endpoints, states in an endpoint or other things.
My current problem is modelling a "Kiosk" (by which I mean rather the german than the english/american concept, but that shouldn't do much to the question :-) ). Currently present:
* /users for the customers,
* /products for the products,
* /carts to save on the server what a customer has already "reserved".
Now I'd like to record an (offline) payment, which will decrease the number of available products, the user's balance, and so on. My understanding would be that this is an operation that would be put in it's own endpoint, so one of:
* POST cart_id=<id> /transactions
* POST /cart/<id>/payment
I have seen other ways to do this by adding a "state" attribute to the cart though, and to transition that from "open" to "paid" for example, and have all the side effects (reduce the number of available products, reduce the balance of the user, maybe other stuff) happen when that transaction happens. I must say I'm not sure I like that approach because it feels like hiding a lot of side effects behind a relatively small change.
Now back to the question. What would you consider the best or most idiomatic way to do this? Is there another way I haven't considered? What are the advantages and disadvantages of one solution vs another, if any?
Thank you for your time,
Felix