> For the complete documentation index, see [llms.txt](https://docs.umbcheckout.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbcheckout.net/v17/core-services/cancellation-tokens.md).

# Cancellation Tokens

Passing a CancellationToken to UmbCheckout's services

Every public async service method in UmbCheckout 17 can take a `CancellationToken`. Pass the request's token (`HttpContext.RequestAborted`, or the `cancellationToken` your notification handler receives), so work stops when the shopper leaves.

* New methods take it as an optional last parameter (`CancellationToken cancellationToken = default`).
* Methods that existed in v13 keep their old signature, and gain an overload with a `CancellationToken` as the last parameter. These overloads are default interface methods that call the old method, so classes that implement the interfaces still compile. The old overloads are `[Obsolete]` and will be removed in the next major version: call the overload with the token (see [Upgrading from v13](/v17/getting-started/upgrading-from-v13.md#breaking-changes)).
* UmbCheckout's own controllers, view components, Forms workflow and notification handlers pass the request's token.
* When a shopper leaves during checkout, the call to Stripe stops, and the request ends quietly (no error page, no error log). A Stripe timeout is logged as a warning.
* A refund's call to Stripe is never cancelled, so it always reaches the audit log.

The services with token overloads are: the session, basket, currency and basket context services; the Stripe session, client factory, line and basket pricing, shipping options and shipping rate services; and, in the add-ons, the cookie service and the Stripe payments, invoices, refunds, customers and tax rate services.

### Mocks and decorators

Because UmbCheckout calls the token overloads:

* a Moq mock set up only for the old overload returns `null` from the new one. Set up the overload with the `CancellationToken`;
* a decorator that overrides only the old method is bypassed. Override the token overload too.

For example, mock `CreateSessionAsync(basket, It.IsAny<CancellationToken>())` rather than `CreateSessionAsync(basket)`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbcheckout.net/v17/core-services/cancellation-tokens.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
