orderItemsCancelWithHttpInfo method
- String id,
- String idempotencyKey, {
- OrderItemCancelRequest? orderItemCancelRequest,
- Future<
void> ? abortTrigger,
Cancel an item
Cancels an order item and refunds what was paid for it, less any cancellation penalty. Available when the item's actions.cancellation is available; while a refund is running it shows inProgress, and manualReview means support must handle it. An item still being delivered cannot be cancelled, and the fulfillmentFailed reason is accepted only for a rejected item; a cancellation that is not valid for the item returns 400 with code 10001. A kind of item that can never be cancelled returns 422 with code 18000 (CANCELLATION_NOT_SUPPORTED). Otherwise a cancellation that is not allowed now returns 409 with code 18001 (CANCELLATION_NOT_AVAILABLE), and details[0].reason repeats actions.cancellation.availability (IN_PROGRESS, MANUAL_REVIEW or NOT_AVAILABLE). The amount is recalculated at this point, so it can differ from an earlier cancellation preview. A refund started by OpenRoam support returns 409. An item of another partner, or an unknown id, returns 404 with code 10004. Returns the orderItemId, the refund amount, the method it is returned to and its status. A balance payment is refunded to the wallet that paid it. Refund progress is also reported by the order-item.refunded webhook. Requires an Idempotency-Key header (a UUID). Repeating a completed request with the same key returns 409 with code 12000 (IDEMPOTENCY_KEY_ALREADY_USED); one still running returns 409 with code 12002 (IDEMPOTENCY_KEY_IN_PROGRESS), and a different body with the same key 409 with code 12001. A request that ended in an error can be sent again with the same key and body.
Note: This method returns the HTTP Response.
Parameters:
-
String id (required): Order item id (
items[].idfrom the order response). -
String idempotencyKey (required): UUID idempotency key for safe retries of this operation.
-
OrderItemCancelRequest orderItemCancelRequest: The cancellation reason.
Implementation
Future<Response> orderItemsCancelWithHttpInfo(String id, String idempotencyKey, { OrderItemCancelRequest? orderItemCancelRequest, Future<void>? abortTrigger, }) async {
// ignore: prefer_const_declarations
final path = r'/api/v1/b2b/order-items/{id}/cancel'
.replaceAll('{id}', id);
// ignore: prefer_final_locals
Object? postBody = orderItemCancelRequest;
final queryParams = <QueryParam>[];
final headerParams = <String, String>{};
final formParams = <String, String>{};
headerParams[r'Idempotency-Key'] = parameterToString(idempotencyKey);
const contentTypes = <String>['application/json', 'text/json', 'application/*+json'];
return apiClient.invokeAPI(
path,
'POST',
queryParams,
postBody,
headerParams,
formParams,
contentTypes.isEmpty ? null : contentTypes.first,
abortTrigger: abortTrigger,
);
}