In short: I want to know if the HTTP method PATCH is ok for my scenario.
I have REST API which checkouts the cart and charges the customer. Essentially endpoint consists of couple steps:
- Get balance
- Charge
- Edit cart order status
Therefore the API charges the client (changes his balance), then confirms the cart order (changes the cart status to confirmed).
According to the old reference : What is the difference between POST and PUT in HTTP?
- POST is used to create a resource or modify it
- PUT is used to create resource if it does not exist or replace, also it is idempotent
According to the : https://www.baeldung.com/rest-http-put-vs-post
- POST is only for resource creation
- PUT definition is the same
Lastly according to the : https://www.baeldung.com/http-put-patch-difference-spring
- PATCH is used for the partial update, can be not idempotent
Therefore in my scenario endpoint is not idempotent, I can cross out the PUT, but in this case I'm lost whenever should I use the POST(which in older SO question was used for update) or PATCH(which now used for partial update). I'm leaning towards the PATCH but it seems like PATCH is used for modification of specific entity, meanwhile POST seems to fit the case but it is no longer used for updating.