> For the complete documentation index, see [llms.txt](https://docs.xaman.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xaman.dev/concepts/payloads-sign-requests/lifecycle/sample-pos-lifecycle.md). Agents can also search and read this documentation through its [MCP server](https://docs.xaman.dev/~gitbook/mcp).

# Sample POS lifecycle

```mermaid
sequenceDiagram
    autonumber

    participant app as Xumm App
    actor user as End user
    participant frontend as Your app Frontend
    participant backend as Your app Backend
    participant xumm as Xumm Backend
    participant xrpl as XRP Ledger (RPC)

    user-->>frontend: "I want to pay"
    frontend->>backend: Amount typed & sent<br />to initiate pament flow
    
    critical Craft Xumm payload
        Note over backend: XRPL Transaction Template with<br />destination account & currency<br />and stable coin amount to pay.
    end
    backend->>frontend: Payload returned<br />Persist the UUID in your own database for reference.<br />Forward the payload JSON to your frontend.
    
    critical Construct payload screen
        Note over frontend: Use the payload information to update the UI<br />Render the `refs.qr_png` as image (QR to scan)<br />Subscribe to the `refs.websocket_status` URL<br />for live status updates.
    end

    par Backend, Frontend and End user react in parallel
        frontend->>user: Show QR to pay with Xumm<br />Shows "Waiting for QR Scan"
        rect rgb(240, 220, 225)
            activate user
                user->>app: Scans QR, opens sign request
            deactivate user
        end
        xumm->>frontend: Sends `opened: true` message over WebSocket
        frontend->>user: Display "Waiting for payment"
    end
    
    xumm->>app: "Sign request" (payment approval screen) rendered for end user
    activate app
    par Sign procedure
        rect rgb(240, 220, 225
            activate user
                user->>app: Approves "Sign request" (makes payment)
            deactivate user
        end
        app->>+xrpl: Transaction submitted to the XRP Ledger
    end

    deactivate app

    xrpl->>-app: Verifies payment & returns status (successful / failed)

    xumm->>frontend: Sends `signed: true` (accepted) or `signed: false` (rejected) message over WebSocket
    frontend->>user: Display "Confirming payment..." (pending...)<br />or "Payment cancelled" (allow retry?)

    xumm->>backend: Sends Webhook with transaction information
    backend->>xumm: Verify payload status & transaction hash
    backend->>xrpl: Verify transaction outcome
    Note over backend,xrpl: Check if the transaction is successful and<br />the `delivered_amount` matches the<br />requested currency and amount.
    backend->>frontend: Update payment status

    frontend->>user: Payment successful, ... / Payment failed, ...
```


---

# 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.xaman.dev/concepts/payloads-sign-requests/lifecycle/sample-pos-lifecycle.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.
