> For the complete documentation index, see [llms.txt](https://docs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.akinon.com/technical-guides/channel-app-template/architecture/services-flows/order-service.md). Agents can also search and read this documentation through its [MCP server](https://docs.akinon.com/~gitbook/mcp).

# Order Service

The Order Service handles actions such as creating, updating, and canceling orders. To perform these actions, it relies on the integrations with OmnitronIntegration and ChannelIntegration.

### *class* OrderService *(object)*

#### Fetch and Create Order

*(self, is\_success\_log=True)*

This function first connects to the Sales Channel and fetches any existing orders. Afterward, it sends the orders to Akinon via the `create_order` function. If an error occurs during the process, an `error_report` is generated in the Sales Channel logs.

#### Create Order

*(self, omnitron\_integration: OmnitronIntegration, channel\_order: ChannelCreateOrderDto)* → Union\[Order, None]

This function enables the transfer of orders from the Sales Channel to Akinon. It sequentially writes the customer and address information from the Sales Channel to Akinon, capturing the responses returned. It also reads the corresponding shipping carrier information from Akinon, ensuring that all the necessary details for creating the order are collected. Finally, the order information is sent to Akinon.

#### Update Orders

*(self, is\_sync=True, is\_success\_log=True)*

This function first connects to Akinon Omnitron and fetches the updated orders that can be transmitted to the Sales Channel. Afterward, it sends these orders to the Sales Channel via the `send_updated_orders` command. Based on the value of the `is_sync` parameter, it determines whether the communication with the Sales Channel will be synchronous or asynchronous. If asynchronous, the necessary records are created via the `batch_service`. If an error occurs during the process, an `error_report` is generated in the Sales Channel logs.

#### Get Order Batch Requests

*(self, is\_success\_log=False)*

This function first connects to Akinon Omnitron and retrieves the `batch_requests` that have been sent to create or update orders and are currently in process. It then queries the Sales Channel using the `check_orders`command. If an error occurs during this process, an `error_report` is generated in the Sales Channel logs. Finally, the response from the Sales Channel is forwarded to Akinon Omnitron, completing the flow.

#### Fetch and Create Cancel

*(self, is\_success\_log=True)*

This function first connects to the Sales Channel and retrieves any canceled orders. It then sends the cancellations to Akinon via the `create_cancel` function. If an error occurs during this process, an `error_report` is generated in the Sales Channel logs.

#### Create Cancel

*(self, omnitron\_integration: OmnitronIntegration, cancel\_order\_dto: CancelOrderDto)*

This function enables the transfer of order cancellations from the Sales Channel to Akinon. It sends the cancellations to Akinon through the `create_order_cancel`command, passing the relevant order cancellations as parameters.

#### Fetch and Update Order Items

*(self, is\_success\_log=True)*

This function first connects to the Sales Channel and fetches the updated orders. It then sends the updates to Omnitron via the `update_order_items` command, updating the details on an `OrderItem` basis. If an error occurs during this process, an `error_report` is generated in the Sales Channel logs.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.akinon.com/technical-guides/channel-app-template/architecture/services-flows/order-service.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
