# How It Works

A merchant creates a checkout session with an amount, currency, and expiry window.&#x20;

1. The buyer sends the corresponding crypto to the designated address.&#x20;
2. The system detects the on-chain transfer, confirms it, and settles the funds to the merchant.&#x20;
3. The merchant can then query the checkout status or receive settlement details through the SDK.&#x20;

This batching of detection and settlement ensures consistent reconciliation and reduces operational complexity for integrators.

{% stepper %}
{% step %}

#### **Create**

The merchant calls `createCryptoCheckout` to generate a new payment session. The session encodes the amount, currency, buyer metadata, expiry, and a client reference for idempotent lookups.
{% endstep %}

{% step %}

#### **Pay**

The buyer is presented with a payment address and amount. They send the specified crypto from any supported chain and wallet.
{% endstep %}

{% step %}

#### **Detect**

City Protocol's payment engine monitors the relevant blockchain(s) for inbound transfers matching the session parameters. No manual confirmation is required.
{% endstep %}

{% step %}

#### **Settle**

Once the transaction is confirmed on-chain, the funds are settled to the merchant's participant account. Settlement details — including transaction hash, chain, and confirmed amount — are normalized and made queryable.
{% endstep %}

{% step %}

#### **Query**

The merchant fetches the checkout at any time using `getCryptoCheckout` with their `clientReference`, receiving the current status and any associated settlement data.
{% endstep %}
{% endstepper %}


---

# Agent Instructions: 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:

```
GET https://city-protocol.gitbook.io/docs/neofinance-as-a-service/payment-module/how-it-works.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
