---
title: "Cancel an order"
description: "Cancel an order that has not yet been completed, with optional refund execution for already-captured payments."
canonical: "https://studio.inttegro.com/guides/cancel-an-order"
format: inttegro-machine-docs/v1
language: "Go"
sdk_version: "v11.0.1"
reader_profile: optional
reader_manifest: "https://studio.inttegro.com/machine/go/readers/index.json"
reader_identification: "Optional: declare your client only if known and your current-session capabilities; use reader_manifest for supplemental recommendations."
preamble_estimated_tokens: 654
model_token_report: "https://studio.inttegro.com/machine/token-report.json"
preamble_questions: 5
preamble_source: "general"
recommended_mcp_tools: ["get_integration_guide","check_integration_readiness","cancel_order"]
estimated_tokens: 2075
token_estimate_method: "utf8_bytes_divided_by_4"
---

## Machine preamble

**Summary:** Cancel an order that has not yet been completed, with optional refund execution for already-captured payments. This Go representation uses the selected SDK's native names wherever Studio has a verified mapping.

### Five questions

#### Q1. When should the reader use Cancel an order?

Use this guide when implementing the complete business outcome rather than an isolated request.

#### Q2. What is authoritative on this page?

The guide owns the business sequence and verification logic. Its linked API references own the exact request, response, state, and error contracts.

#### Q3. What page-specific constraint matters most?

Keep the documented ordering, trust boundary, idempotency behavior, and authoritative read-after-write verification intact.

#### Q4. Can Inttegro MCP materially help with this task?

Yes, when the reader has an authenticated MCP connection and the task needs live context, guided planning, or a supported operation. The strongest matches are `get_integration_guide`, `check_integration_readiness`, `cancel_order`; their exact roles and boundaries are listed below.

#### Q5. How should the reader verify the answer and continue?

Use the guide’s explicit completion condition and verify the final resource through the documented lookup or lifecycle state; a successful redirect or accepted request may be intermediate. Continue with [Cancel an order](https://studio.inttegro.com/machine/go/api/orders.md#cancel-an-order) and [Page through orders](https://studio.inttegro.com/machine/go/api/orders.md#page-through-orders) when those concerns enter scope.

### Recommended MCP assistance

Use these through an authenticated Inttegro MCP connection. This document remains the contract source.

- [`get_integration_guide`](https://studio.inttegro.com/machine/go/inttegro-mcp/tools.md#get_integration_guide) — read-only integration guidance. Returns a focused implementation sequence and canonical Studio links for authentication, checkout, orders, catalog, messaging, idempotency, or testing.
- [`check_integration_readiness`](https://studio.inttegro.com/machine/go/inttegro-mcp/tools.md#check_integration_readiness) — read-only integration guidance. Audits platform secret storage, server-runtime compatibility, idempotency, errors, state verification, checkout returns, and messaging consent without receiving source code or credentials.
- [`cancel_order`](https://studio.inttegro.com/machine/go/inttegro-mcp/tools.md#cancel_order) — action; exact user confirmation required. Cancels an eligible order without requesting or executing a refund.

## Document content

# Cancel an order

Orders that haven't reached `"completed"` status can be canceled at any point in the lifecycle—whether the customer changed their mind before paying, an item went out of stock, or a suspected fraudulent transaction needs to be voided immediately. This guide shows you when cancellation is appropriate, how to trigger it, and what to expect from the order and payment objects afterward.

> Mcp Guide Callout is interactive content. Use the canonical page to view it.

## Prerequisites

- An order ID (`or_…`) that you want to cancel
- Familiarity with [the order lifecycle](https://studio.inttegro.com/machine/go/guides/order-lifecycle.md)

## When to cancel

Cancellation is the right action when the order should never complete. Common cases:

- **Customer request before payment** — The customer abandoned the checkout or called in to withdraw. The order is in `"requires_payment"` and no money has moved yet.
- **Out-of-stock after order creation** — You accepted the order but can't fulfill it. Cancel immediately to avoid the customer waiting on a payment that will never ship.
- **Duplicate or fraudulent order** — Your fraud detection flagged the transaction before it completed. Cancel with reason `"fraud"` for your audit trail.
- **Timeout or expiry** — You want to programmatically clean up stale orders that sat in `"requires_payment"` past your SLA.

**What cancellation does not cover:** If the order has already reached `"completed"` status, you need a refund flow, not a cancellation. Cancellation is pre-completion only.

## Cancel an order without refund

When the order has no captured payment—typically orders still in `"requires_payment"` before the customer confirms the OTP, or orders in `"preparing"` that were never paid—cancel without triggering a refund. Set `execute_refund` to `false` or omit it entirely.

**Cancel order — POST /orders/cancel**

```go
package main

import (
  "context"
  "log"
  "os"

  inttegro "github.com/inttegro/inttegro-sdk-go/v11"
)

func main() {
  ctx := context.Background()
  client := inttegro.NewClient(os.Getenv("INTTEGRO_API_KEY"))

  result, err := client.Orders.Cancel(ctx, "or_kAVwBsk6EhQVv2YBUhYAqMf0lktEoQ0S7ZR8y2xi")
  if err != nil {
    log.Fatal(err)
  }
  _ = result
}
```

After a successful cancellation the order's [`Order.Status`](https://pkg.go.dev/github.com/inttegro/inttegro-sdk-go/v11@v11.0.1/order#Order) field becomes `"canceled"` and the payment (if one exists) transitions to `"canceled"` as well. The [`CanceledAt`](https://pkg.go.dev/github.com/inttegro/inttegro-sdk-go/v11@v11.0.1/order#Order) timestamp is set on the payment object for your audit trail.

## Cancel an order and refund the customer

If the customer's mobile money payment was already charged before you cancel, pass `execute_refund`: `true`. Inttegro voids or reverses the payment in the same call—you don't need a separate refund API call.

**Cancel with refund — POST /orders/cancel**

```go
package main

import (
  "context"
  "log"
  "os"

  inttegro "github.com/inttegro/inttegro-sdk-go/v11"
)

func main() {
  ctx := context.Background()
  client := inttegro.NewClient(os.Getenv("INTTEGRO_API_KEY"))

  result, err := client.Orders.Cancel(ctx, "or_kAVwBsk6EhQVv2YBUhYAqMf0lktEoQ0S7ZR8y2xi")
  if err != nil {
    log.Fatal(err)
  }
  _ = result
}
```

Refund timing depends on the payment method. Mobile money reversals typically settle within minutes.

## What happens after cancellation

Once canceled, an order cannot be reopened or modified. The cancellation is permanent. If the customer still wants to buy, create a new order.

The canceled order remains accessible via [Lookup an order](https://studio.inttegro.com/machine/go/api/orders.md#lookup-an-order) and [Page through orders](https://studio.inttegro.com/machine/go/api/orders.md#page-through-orders). It appears in your order history with [`Status`](https://pkg.go.dev/github.com/inttegro/inttegro-sdk-go/v11@v11.0.1/order#Order): `"canceled"` indefinitely—useful for customer service, auditing, and financial reconciliation.

Your balance is not affected by a cancellation unless a payment was already captured and you set `execute_refund`: `true`. In that case, a negative balance transaction is created for the refund amount, reducing your available balance by the refunded sum.

## Related resources

- [Cancel an order](https://studio.inttegro.com/machine/go/api/orders.md#cancel-an-order) — API reference with all parameters
- [The order lifecycle](https://studio.inttegro.com/machine/go/guides/order-lifecycle.md) — Understand which statuses allow cancellation
- [Lookup an order](https://studio.inttegro.com/machine/go/api/orders.md#lookup-an-order) — Verify the order status after cancellation
