ordersCreateOrderWithHttpInfo method
- String idempotencyKey, {
- MixedOrderRequest? mixedOrderRequest,
- Future<
void> ? abortTrigger,
Create an order
Places one order of one to five items, of one or several product types, and pays it from the wallet. Each item names its productType, the publicId of the offer from search or quote, a quantity and, where the product needs them, product-specific inputs (required for hotels and flights). An order has at most five items and a total quantity of at most five; an item with quantity n becomes n separate order items, each with its own items[].id. Every item is validated before anything is charged; a rejected item is reported at items[i] in details, for example 11004 (OFFER_EXPIRED_OR_INVALID) for an unknown, expired or other-product publicId, 11003 (OFFER_UNAVAILABLE) or 11002 (OFFER_PRICE_CHANGED). The optional maxTotal { amount, currency } caps the whole order: the sum of every item's price times its quantity, in the order currency. Its currency must be the order currency (otherwise 400, 10001, CURRENCY_MISMATCH at maxTotal.currency). A higher total returns 409 with code 11002 (OFFER_PRICE_CHANGED) at maxTotal, after every item is priced and before anything is charged; a total equal to it is accepted. The order total is charged to the partner's selected wallet. On success the order is paid and its items start as pending; delivery continues after the response, so follow it with GET orders/{id}, GET orders/{orderId}/fulfillment/status or the order.fulfillment.updated webhook. If the charge fails the order stays paymentPending, payment.failure carries 16000 (PAYMENT_FAILED) and the response is still 200; top up the wallet and call payment retry. Requires an Idempotency-Key header (a UUID) per purchase. Repeating the same request with the same key never charges twice: once the order is accepted it returns 200 with that order's current state; while the first request is still running it returns 202 with code 12002 (IDEMPOTENCY_KEY_IN_PROGRESS) and a Retry-After header, after which you send the same request again; a different body with the same key returns 409 with code 12001 (IDEMPOTENCY_KEY_REQUEST_MISMATCH). After a timeout or 5xx, retry with the same key and body rather than a new key. A referenceId already used by another order of the partner returns 409 with code 10005 (CONFLICT).
Note: This method returns the HTTP Response.
Parameters:
-
String idempotencyKey (required): UUID idempotency key for safe retries of this operation.
-
MixedOrderRequest mixedOrderRequest: The order to place.
Implementation
Future<Response> ordersCreateOrderWithHttpInfo(String idempotencyKey, { MixedOrderRequest? mixedOrderRequest, Future<void>? abortTrigger, }) async {
// ignore: prefer_const_declarations
final path = r'/api/v1/b2b/orders';
// ignore: prefer_final_locals
Object? postBody = mixedOrderRequest;
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,
);
}