Refactor checkout