Our current purchase flow is the following:
- Create order
- Add accommodation item 1
- Add accommodation item 2...
- Finalize order
- Do payments
This happens all at the same time on payment. It worked because a user would generally only add one or two items to an order at a time but as we are adding new types of items to an order this will not scale.
One approach would be to bundle all the items into a singular request and add them at the same time. We will setup some kind of polling or workers from order to flights:
- Create order with items and finalize
- Do payments
- We only have one request so potential network dropouts are limited
- It will be quicker as the network roundtrip is minimized
- Some items could take a long time to be added (flights). This means we will potentially hit the heroku timeout of 30s. We would need to solve this by polling or something similar
- An order will be blocked by a single item even though the rest have been added. For example we book 2 hotel rooms, 3 addons and then the flights price has changed so that item is rejected. The user would have to start again and the order be cleaned up (already solved).
We could also continue to add the items to the order individually.
- Create order on calendar page
- Add the hotel after calendar
- Add the addons
- Add flights after traveller form
- Finalize
- Do payments
- Item inventory is locked down for a user at the time it's added
- Less chance of the user being rejected at payment as the items are already in the order
- Individual requests mean we wont hit the network timeout
- Inventory is taken before a user decides to pay. We could book out hotels without selling any
- The client must keep track of the order state. Items will need to be updateable/deleteable from an order (no small feat)
- We will need to handle orders being abandoned. This means showing a clock or something similar (19:59 minutes remaining)
Feel free to edit and add solutions