cancelInvoice

@HTTP(method = "DELETE", path = "/collection/{apiVersion}/invoice/{referenceId}", hasBody = true)
abstract suspend fun cancelInvoice(@Path(value = "referenceId") referenceId: String, @Path(value = "apiVersion") apiVersion: String, @Body invoiceCancellation: InvoiceCancellation, @Header(value = "Ocp-Apim-Subscription-Key") productSubscriptionKey: String, @Header(value = "X-Reference-Id") uuid: String): Response<Unit>

Cancels a pending invoice before it is paid or expires.

MTN's cancel-invoice endpoint is a DELETE that carries a JSON body (InvoiceCancellation), so this uses @HTTP with hasBody = true rather than a plain @DELETE.

The invoice being cancelled is identified by the body's externalId (the value used when the invoice was created).

Return

A Response with an empty body; HTTP 200 indicates successful cancellation.

Parameters

referenceId

Per MTN: the UUID of the transaction used to get the result — uniquely identifies this invoice cancellation (URL path).

apiVersion

The API version to target (e.g., v1_0 or v2_0).

invoiceCancellation

The request body; its externalId (reused from invoice creation) identifies the invoice.

productSubscriptionKey

The Ocp-Apim-Subscription-Key for the Collection product.

uuid

The X-Reference-Id header. Per MTN: the UUID V4 resource ID of the transaction, used e.g. for validating the status of the request.