> For the complete documentation index, see [llms.txt](https://docs.tiun.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tiun.io/guides/testing/test-flows.md).

# Test flows

Use this checklist while validating a tiun integration in **sandbox** — the parallel test environment with its own domain, snippet ID, product IDs (`p-test-...`), and API keys. Items are grouped by product type so you can focus on what applies to your integration.

## General (all product types)

* Overlay opens when triggered (`tiun.checkout()` for subscriptions and one-time purchases, `tiun.start()` for time-based).
* Test payment methods complete successfully — see [Simulate payments](/guides/testing/simulate-payments.md) for test cards and the PayPal simulator.
* A failed payment (declining test card or **Fail test setup** in the PayPal flow) grants no access and surfaces through the SDK **`error`** event so you can log or show UI.
* Overlay closes cleanly after success or cancel.
* If you verify purchases or sessions on your server, requests use the **sandbox** base URL and a **sandbox** API key (not shared with live). Replace both with live URL and key when you ship.

## Subscriptions

* `userChange` fires after checkout with `event: 'checkout'` and updated `productAccess`.
* Login and logout behave correctly (see [authenticating your user](/guides/authentication/authenticate-your-user.md)).
* After a successful purchase, `productAccess` includes the expected product ID.
* Returning to the app restores the user session without forcing login (`userChange` with `event: 'init'`).
* After cancelling the test subscription in the [account portal](/guides/testing/simulate-payments.md#cancellation-and-expiration), the product ID is removed from `productAccess` and `userChange` fires.

## One-time purchases

* The checkout overlay shows the **fixed fee** with no billing interval or trial.
* `userChange` fires after checkout with `event: 'checkout'` and the product ID in `productAccess`.
* Returning to the app restores the purchase without forcing login (`userChange` with `event: 'init'`).
* After logging out and back in with the same email, the product ID is **still** in `productAccess` — one-time purchases don't expire, so there's no cancellation path to test.
* Your sales page offers a **log in** option, not only a buy button, so a returning customer isn't pushed to pay twice.

## Time-based billing

* `paywallShow` fires when the user doesn't have access.
* `paywallHide` fires when access is granted and a session is active — payload includes a `sessionId`.
* `setContent()` pauses and resumes sessions correctly across content types.
* Switching between paid and free content updates the session state as expected.

***

For sandbox vs. live setup, see [setting up your environment](/guides/getting-started/set-up-environment.md). For how the two environments differ, see [Sandbox](/reference/generic/sandbox.md) in Reference.


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.tiun.io/guides/testing/test-flows.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
