# Build with AI

Working with Claude, ChatGPT, Copilot, or another assistant? Copy the prompt below into your AI tool of choice to scaffold your Windows POSLink integration.

```admonition
icon: fas fa-copy
title: Feed it the full docs
content: Every page on this portal has a "Copy as Markdown" button in the top right. Paste the pages the prompt references into your AI's context for the best results, or point it at the OpenAPI specs on the Downloads page.
link: /downloads
```

```text
You are helping me integrate my Windows ePOS application with Teya card machines using the
Teya Unified ePOS SDK (POSLink: my ePOS and the Teya card machine are separate devices).

My stack: [describe your app language/framework, e.g. C#/.NET]

Key facts:
- On Windows, the SDK ships as a distributable executable, not a library. Get the current
  version from https://docs.teya.com/downloads - the zip contains the executable plus a
  public certificate for verifying its signature (optional but recommended). Do not guess
  the download URL; take it from that page.
- My application starts this executable as a sub-process and communicates with it over
  JSON-RPC (https://www.jsonrpc.org/specification) via the sub-process's standard input and
  output. Each message is a single line of JSON with no embedded newlines. I need a single
  background task continuously reading standard output, matching each response to its
  request by the JSON-RPC "id" field (e.g. via a Dictionary of pending requests).
- I need a Client ID and Client Secret from the Teya Developer Portal (partner.teya.xyz for
  development, partner.teya.com for production). This is one set for my whole application,
  not one per merchant - merchants authenticate separately with their own Teya ID.
- Right after starting the sub-process, call the "initialize" method with params:
  requesterId (my app's identifier), requesterVersion, isProductionEnv, clientId,
  clientSecret, and optionally eposInstanceId. It responds with
  { "type": "initialize->ack", "integrations_app_version": "..." }.
- Then call the "setup" method (no params). The first time, it shows UI guiding the merchant
  to log in with their Teya account and select a store and card machine. It responds with
  { "type": "setup->onResponse", "response": "SUCCESS" | "CANCELED" | "SERVER_ERROR", ... },
  including store and terminal details on SUCCESS. I must call setup before any transaction
  methods.
- "getTerminals" (param forceRefresh: bool) lists card machines for the linked store, and
  "linkTerminal" (param terminalId: string or null) switches the linked card machine or shows
  the SDK's terminal-selection UI.
- To make a payment, call "makePaymentAndSubscribe" with params: transactionId, amount
  (total in minor units, tip included not on top), tip (optional, minor units), currency
  (ISO 4217 code e.g. "GBP"), and useTeyaDefaultUi (true to show the SDK's built-in
  in-progress UI). It responds (and sends further notifications) of type
  "makePaymentAndSubscribe->onPaymentStateChanged" with a "state" field for the payment
  status.
- Error responses use a JSON-RPC "error" object instead of "result", with codes -1
  (INVALID_REQUEST_FORMAT), -2 (INVALID_STATE - e.g. calling before initialize/setup), and
  -3 (ILLEGAL_ARGUMENT_EXCEPTION).

Documentation to follow (read these before writing code):
- https://docs.teya.com/epos-sdk/poslink/windows/getting-started
- https://docs.teya.com/epos-sdk/poslink/windows/make-payment
- https://docs.teya.com/epos-sdk/overview

Task: start the SDK executable as a sub-process, implement the JSON-RPC request/response
plumbing over stdin/stdout, call initialize then setup, and implement a basic
makePaymentAndSubscribe call with result handling. Follow the documentation exactly and do
not invent methods or fields - if unsure, tell me to check the docs page rather than
guessing.
```
