Creating and updating orders
The ability to create and pay for goods or services is an integral part of the e-commerce application. In this section, you can familiarize yourself with the principles of working with orders.
To create and update orders, authorization is required
Kotlin Multiplatform
Order Creation
val address = "New York"
val comment = "Comment"
val catalog = CatalogService.all(limit = 3).items
val order = OrdersService.create(
marker = "delivery",
formIdentifier = "delivery",
paymentAccountIdentifier = "stripe"
) {
formData {
locale("en_US") {
put("address", AttributeValue.fromString(address))
put("comment", AttributeValue.fromString(comment))
}
}
products {
catalog.forEach {
put(
id = it.id,
quantity = Random.nextInt(1, 10)
)
}
}
}
Order Updating
If you know the order identifier, you can update its information:
val id: Int = // ...
OrdersService.update(
id = order.id,
marker = "delivery",
formIdentifier = "delivery",
paymentAccountIdentifier = "stripe"
) {
formData {
locale("en_US") {
put("address", AttributeValue.fromString("Los Angeles"))
}
}
}
Swift
Order Creation
let address = "New York"
let comment = "Test comment"
let catalog = try await CatalogService.shared.all(limit: 3).items()
let order = try await OrdersService.shared.create(
marker: "delivery",
formIdentifier: "delivery",
paymentAccountIdentifier: "stripe"
) {
FormDataContainer {
Locale("en_US") {
FormData(marker: "address", attribute: .init(string: address))
FormData(marker: "comment", attribute: .init(string: comment))
}
}
ProductsContainer {
for product in catalog {
OrderProduct(
id: product.id,
quantity: .random(in: 1...10)
)
}
}
}
Order Updating
If you know the order identifier, you can update its information:
let id = // ...
let status = "delivered"
let order = try await OrdersService.shared.update(
id: id,
marker: "delivery",
formIdentifier: "delivery",
paymentAccountIdentifier: "cash"
) {
OrderStatus(status)
FormDataContainer {
Locale("en_US") {
FormData(marker: "address", attribute: .init(string: "Los Angeles"))
}
}
}
Last modified: 01 August 2025