Order Replacement and Weight Change Actions
This document describes all order-level actions related to product replacement, weight changes, capture, and additional payment handling.
Each action includes endpoint definitions, request/response structures, validation rules, business constraints, audit behavior, and configuration dependencies.
1. Capture Order
This action is executed only once per order.
It captures the order’s previously authorized transaction. This operation converts the prior authorization obtained from the customer into an actual payment.
Endpoint
POST /api/v1/orders/{order_id}/capture_order/Request Example
POST /api/v1/orders/12345/capture_order/
Authorization: Token your_token_here
Content-Type: application/json
{
"force_refund": false
}Request Parameters
force_refund(boolean, optional, default:false)If the order already has a purchase transaction, setting this value to
truetriggers a refund for the excess amount and applies a capture-like behavior.
Response Example
Business Rules
This action must be executed only once per order.
If the order has an authorized transaction, the order status cannot be
waiting_for_substitute.Otherwise,
FinalizeCaptureWaitingPaymentExceptionis raised.
Concurrent capture attempts are blocked.
A cache lock prevents multiple captures on the same order for 60 seconds.
The order total amount is validated via:
The order must have either:
an authorize transaction, or
a purchase transaction
Otherwise,
OrderCaptureExceptionis raised.
If
force_refund = trueand the order already has a purchase transaction:The excess amount of the purchase transaction is refunded.
If the order status is
confirmation_waiting, it is updated toapproved.An audit log entry is created with action:
ENV & Dynamic Settings
ENV: None
Dynamic Settings: None
2. Bulk Replace Products
It bulk replaces the products of multiple order items in an order.
The existing order items are canceled, and new order items are created with the new products.
Endpoint
Request Example
Request Parameters
order_item(integer, optional): ID of the order item to be replaced.new_product_sku(string, optional): SKU of the replacement product.
Validation Note
At least one of
order_itemornew_product_skumust be provided.If both are missing, serializer validation fails.
Response Example
Business Rules
Each request item must include at least one of the
order_itemornew_product_skuparameters. If neither is provided, a serializer validation error is raised.The order status must be one of the following:
confirmation_waitingapprovedpreparingOtherwise,OrderItemChangeOrderNotAllowedExceptionis raised.
The order’s channel type must be
web. Otherwise,OrderItemChangeOrderNotAllowedExceptionis raised.The order transaction is validated (
validate_transaction()).The order must not have been sent to the ERP system (
is_send=False). Otherwise,OrderItemReplacementOrderIsSendExceptionis raised.For each order item:
The order item must not have an active cancellation plan.
The order item status must be one of:
waiting,payment_waiting,confirmation_waiting,approved,preparing.The new product must belong to the same catalog.
The new product must be in the same stock list.
The stock quantity of the new product must not be less than the order item’s quantity.
The stock unit type must be
quantity.The price of the new product must be greater than the order item’s total benefit share amount.
If the new order amount is greater than the previous amount:
The
ORDER_ITEM_UPPER_PRICE_ENABLEdynamic setting must be enabled. Otherwise,OrderItemPriceExceedsCurrentPriceExceptionis raised.The order status is updated to
waiting_for_substitute.A
create_replacement_orderevent is sent to Commerce.
The existing order items are canceled (
status=cancelled,price=0).New order items are created.
The order amount is recalculated.
An audit log entry is created with the action:
ENV & Dynamic Settings
ENV: None
Dynamic Settings
ORDER_ITEM_PRODUCT_UPDATE_AVAILABLE(boolean, default:false): Determines whether order item product updates are enabled.ORDER_ITEM_UPPER_PRICE_ENABLE(boolean, default:false): Allows the new product price to be higher than the existing price.
3. Bulk Reduce Weights
It bulk reduces the weights of multiple order items in an order. This operation is used for products sold by kilogram.
This action does not allow weight increase.
Endpoint
Request Example
Request Parameters
order_item(integer, required): The ID of the order item whose weight will be changed.new_weight(decimal, required): The new weight value (in kilograms).
Response Example
Business Rules
The
ORDER_ITEM_PRODUCT_UPDATE_AVAILABLEdynamic setting must be enabled OR theORDER_ITEM_WEIGHT_KEYsetting must be defined. Otherwise,OrderItemReplacementNotEnabledExceptionis raised.The order transaction is validated by calling
validate_transaction().For each order item:
The order item must not have an active cancellation plan.
The order item status must be one of the following:
waiting,payment_waiting,confirmation_waiting,approved,preparing.The stock unit type must be
kilogram.The
ORDER_ITEM_WEIGHT_KEYkey must exist in the order item’sattributesfield.The new weight must be different from the previous weight.
The price is recalculated based on the weight change ratio:
new_price = old_price * (new_weight / old_weight)If
new_weight = 0, the order item price is set to0, and all benefit applicants are cancelled.
The order item’s
attributesfield is updated as follows:old_{ORDER_ITEM_WEIGHT_KEY}: stores the previous weight{ORDER_ITEM_WEIGHT_KEY}: stores the new weight
If the new order total amount is greater than the previous total:
The
ORDER_ITEM_UPPER_PRICE_ENABLEdynamic setting must be enabled. Otherwise,OrderItemPriceExceedsCurrentPriceExceptionis raised.The order status is updated to
waiting_for_substitute.A
create_replacement_orderevent is sent to Commerce.
The order total amount is recalculated.
An audit log entry is created with the action:
ENV & Dynamic Settings
ENV
ORDER_ITEM_WEIGHT_KEY(string, default:None): The key name used to store weight information in the order item’sattributesfield (e.g."unit_weight").
Dynamic Settings
ORDER_ITEM_PRODUCT_UPDATE_AVAILABLE(boolean, default:False): Determines whether order item updates are enabled.ORDER_ITEM_UPPER_PRICE_ENABLE(boolean, default:False): Allows the price calculated from the new weight to be higher than the previous price.
4. Bulk Replace Product and Reduce Weight
Replaces the products of multiple order items in an order and/or reduces their weights. This action allows both product replacement and weight reduction to be performed within the same request.
Endpoint
Request Example
Request Parameters
order_item(integer, optional): The ID of the order item to be updated.new_product_sku(string, optional): The SKU of the new product (for product replacement).new_weight(decimal, optional): The new weight value (for weight reduction).
Notes:
new_product_skuandnew_weightcannot be provided at the same time. If both are provided, a validation error is raised.At least one of
new_product_sku,new_weight, ororder_itemmust be provided. If none are provided, a validation error is raised.
Response Example
Business Rules
Each request item must include at least one of the following parameters:
new_product_sku,new_weight, ororder_item. If none are provided, a serializer validation error is raised.new_product_skuandnew_weightcannot be provided together in the same request item. If both are provided, a serializer validation error is raised.The
ORDER_ITEM_PRODUCT_UPDATE_AVAILABLEdynamic setting must be enabled OR theORDER_ITEM_WEIGHT_KEYsetting must be defined. Otherwise,OrderItemReplacementNotEnabledExceptionis raised.The order transaction is validated by calling
validate_transaction().For each order item:
If
new_product_skuis provided, all business rules of thebulk_replace_productsaction apply.If
new_weightis provided, all business rules of thebulk_reduce_weightsaction apply.
Product replacement and weight reduction can both be applied to the same order item, executed sequentially.
If the new order total amount is greater than the previous total:
The
ORDER_ITEM_UPPER_PRICE_ENABLEdynamic setting must be enabled. Otherwise,OrderItemPriceExceedsCurrentPriceExceptionis raised.The order status is updated to
waiting_for_substitute.A
create_replacement_orderevent is sent to Commerce.
The order total amount is recalculated.
An audit log entry is created with the action:
ENV and Dynamic Settings
ENV
ORDER_ITEM_WEIGHT_KEY(string, default:None): The key name used to store weight information in the order item’sattributesfield.
Dynamic Settings
ORDER_ITEM_PRODUCT_UPDATE_AVAILABLE(boolean, default:False): Determines whether order item updates are enabled.ORDER_ITEM_UPPER_PRICE_ENABLE(boolean, default:False): Allows the new price to be higher than the previous price.
5. Bulk Change Weight
Updates the weights of multiple order items within an order in bulk (the weight can be increased or decreased).
The difference from the bulk_reduce_weights action is that this action also allows weight increases.
Endpoint
Request Example
Request Parameters
order_item(integer, required): The ID of the order item whose weight will be changed.new_weight(decimal, required): The new weight value (in kilograms).
Response Example
Business Rules
The
ORDER_ITEM_UPPER_PRICE_ENABLEdynamic setting must be enabled. Otherwise,OrderItemPriceExceedsCurrentPriceExceptionis raised.The
ORDER_ITEM_PRODUCT_UPDATE_AVAILABLEdynamic setting must be enabled OR theORDER_ITEM_WEIGHT_KEYsetting must be defined. Otherwise,OrderItemReplacementNotEnabledExceptionis raised.The order transaction is validated by calling
validate_transaction().All business rules of the
bulk_reduce_weightsaction apply.The weight may be increased or decreased, but it must be different from the previous weight.
If the new order total amount is greater than the previous total:
The order status is updated to
waiting_for_substitute.A
create_replacement_orderevent is sent to Commerce.
The order total amount is recalculated.
An audit log entry is created with the action:
ENV and Dynamic Settings
ENV
ORDER_ITEM_WEIGHT_KEY(string, default:None): The key name used to store weight information in the order item’sattributesfield.
Dynamic Settings
ORDER_ITEM_PRODUCT_UPDATE_AVAILABLE(boolean, default:False): Determines whether order item updates are enabled.ORDER_ITEM_UPPER_PRICE_ENABLE(boolean, default:False): MANDATORY – must be enabled for this action.
6. Bulk Replace Product and Change Weight
Allows replacing products and/or changing the weight of multiple order items within an order.
Unlike the bulk_replace_product_and_reduce_weight action, this endpoint allows both increasing and decreasing the weight.
Endpoint
Request Example
Request Parameters
order_item(integer, required): ID of the order item to be updatednew_product_sku(string, optional): SKU of the new product to replace the existing onenew_weight(decimal, optional): New weight value for the order item
Validation Rules
order_itemis required for each request item.At least one of
new_product_skuornew_weightmust be provided.new_product_skuandnew_weightcannot be provided together in the same request item.If both are provided, a serializer validation error is raised.
new_weightmust be different from the current weight (both increase and decrease are allowed).
Response Example
Business Rules
The
ORDER_ITEM_UPPER_PRICE_ENABLEdynamic setting must be enabled.Otherwise,
OrderItemPriceExceedsCurrentPriceExceptionis raised.
At least one of the following conditions must be met:
ORDER_ITEM_PRODUCT_UPDATE_AVAILABLEdynamic setting is enabledORDER_ITEM_WEIGHT_KEYENV setting is definedOtherwise,
OrderItemReplacementNotEnabledExceptionis raised.
The order transaction is validated (
validate_transaction()).All business rules defined for the
bulk_replace_product_and_reduce_weightaction also apply.The order total amount is recalculated.
If the new order amount is greater than the previous amount:
Order status is updated to
waiting_for_substitute.A
create_replacement_orderevent is sent to Commerce.
An audit log is created after the operation
Action name:
order_bulk_replace_product_and_change_weight
ENV and Dynamic Settings
ENV
ORDER_ITEM_WEIGHT_KEY(string, default:None): Key name used to store weight information in the order item’sattributesfield
Dynamic Settings
ORDER_ITEM_PRODUCT_UPDATE_AVAILABLE(boolean, default:False): Determines whether order item updates are enabledORDER_ITEM_UPPER_PRICE_ENABLE(boolean, default:False): MANDATORY – Must be enabled for this action
7. Waive Additional Payment
Cancels a pending additional payment (pay later) request for an order and updates the order status to preparing.
This action is used when an order is waiting for an additional payment from the customer, but the payment request is waived.
Endpoint
Request Example
Request Parameters
This action does not require a request body.
Response Example
Business Rules
The order status must be
waiting_for_substitute.Otherwise,
PayLaterInfoInvalidOrderStatusExceptionis raised.
The order must have an active
PayLaterInforecord withstatus=payment_waiting.If not found,
PayLaterInfoNotFoundFromOrderExceptionis raised.
The order status is updated to
preparing.The related
PayLaterInforecord is updated towaived.The operation is executed within an atomic transaction.
ENV and Dynamic Settings
ENV: None
Dynamic Settings: None
General Notes
Error Handling
All actions may raise the following exceptions under relevant conditions:
OrderItemHasActiveCancellationPlanExceptionThe order item has an active cancellation plan.
OrderItemReplacementNotAllowedExceptionOrder item replacement is not allowed.
OrderItemReplacementOrderIsSendExceptionThe order has already been sent.
OrderItemPriceExceedsCurrentPriceExceptionThe new price exceeds the current price and
ORDER_ITEM_UPPER_PRICE_ENABLEis disabled.
OrderCaptureExceptionThe order transaction cannot be captured.
PayLaterInfoNotFoundFromOrderExceptionNo pay later information exists for the order.
Audit Logs
All actions create an audit log entry. These logs are used to track and audit order-related operations.
Channel Integration
Some actions (product replacement, weight change) send events to Commerce:
order_item_create– When a new order item is createdorder_item_update– When an order item is updatedorder_update– When the order is updatedcreate_replacement_order– When an additional payment is required
Transaction Validation
All replacement-related actions validate the order transaction:
The order must not be captured
The transaction must be in authorize or purchase state
Last updated
Was this helpful?

