utilityCreateOrderWithHttpInfo method

Future<Response> utilityCreateOrderWithHttpInfo(
  1. String idempotencyKey, {
  2. UtilityOrderRequest? utilityOrderRequest,
  3. Future<void>? abortTrigger,
})

Pay utility bills

Places a utility bill payment order and returns the accepted order. Takes the same body as quote and needs the manage order permission (403 / 10003 without it). An Idempotency-Key header with a new UUID is required for every purchase: a retry with the same key and body returns the order already accepted, 202 / 12002 with Retry-After while it is still being accepted, and a changed body gives 409 / 12001. Every price is recalculated: a current price above inputs.maxPrice gives 409 / 11002 at items[i].inputs.maxPrice before anything is charged, and without inputs.maxPrice the current price is charged. The item is fulfilled when the payment is confirmed and, for a token biller, the token is returned; track it with the order routes or the order.fulfillment.updated webhook.

Note: This method returns the HTTP Response.

Parameters:

  • String idempotencyKey (required): UUID idempotency key for safe retries of this operation.

  • UtilityOrderRequest utilityOrderRequest:

Implementation

Future<Response> utilityCreateOrderWithHttpInfo(String idempotencyKey, { UtilityOrderRequest? utilityOrderRequest, Future<void>? abortTrigger, }) async {
  // ignore: prefer_const_declarations
  final path = r'/api/v1/b2b/utility/order';

  // ignore: prefer_final_locals
  Object? postBody = utilityOrderRequest;

  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,
  );
}