path-terminal-init 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -0
- package/dist/cli.js +725 -0
- package/dist/init.js +6805 -0
- package/package.json +50 -0
- package/rules/android/path-integration-android.mdc +325 -0
- package/rules/ios/path-integration.mdc +393 -0
- package/rules/windows-10/path-integration-windows10.mdc +238 -0
- package/rules/windows-11/path-integration-windows11.mdc +230 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: >
|
|
3
|
+
Rules for AI agents integrating the Path Terminal SDK into a Windows 11 EPOS
|
|
4
|
+
application — the modern WinUI 3 / .NET 10 stack. Apply when the user asks to
|
|
5
|
+
integrate payments, connect to a payment terminal, wire a sale or refund, or
|
|
6
|
+
set up the Path emulator on a WinUI 3 app. For the legacy WPF / .NET Framework
|
|
7
|
+
4.8 stack use path-integration-windows10.mdc instead.
|
|
8
|
+
globs:
|
|
9
|
+
- "**/*.cs"
|
|
10
|
+
- "**/*.csproj"
|
|
11
|
+
- "**/*.xaml"
|
|
12
|
+
- "**/Package.appxmanifest"
|
|
13
|
+
alwaysApply: false
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Path Terminal SDK — Windows 11 (WinUI 3 / .NET 10) Integration Rules
|
|
17
|
+
|
|
18
|
+
You are integrating the Path Terminal SDK into an existing **WinUI 3 / .NET 10**
|
|
19
|
+
Windows EPOS application. This app is a **developer EPOS system** that replicates a
|
|
20
|
+
production environment.
|
|
21
|
+
|
|
22
|
+
> **Which recipe am I in?** This is the **Windows 11** recipe — modern WinUI 3,
|
|
23
|
+
> `net10.0-windows`. If the project is WPF / `net48` (a `<UseWPF>true` csproj
|
|
24
|
+
> targeting .NET Framework 4.8), STOP and use `path-integration-windows10.mdc`
|
|
25
|
+
> instead. The two stacks differ in app shell, UI threading, and settings storage.
|
|
26
|
+
|
|
27
|
+
You have access to the Path MCP server at mcp.path2ai.tech:
|
|
28
|
+
- Tools: `get_code_example` (use platform='windows'), `explain_error`. Always call
|
|
29
|
+
`get_code_example` before writing SDK code — never guess at SDK patterns.
|
|
30
|
+
|
|
31
|
+
> **Language override.** Never write "Pico W" in any output or code comment.
|
|
32
|
+
> Always use "Path POS Emulator" when referring to the physical device.
|
|
33
|
+
|
|
34
|
+
> **Confirm the correct project directory first.** Run `pwd` (or `Get-Location`)
|
|
35
|
+
> before anything. If the path contains `.Trash`, `tmp`, or `worktree`, stop — ask
|
|
36
|
+
> the developer to relaunch from the real project directory.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## The purpose of this integration
|
|
41
|
+
|
|
42
|
+
Wire the SDK so the user can **prove the payment functions against the Path POS
|
|
43
|
+
Emulator, then switch — themselves, in the app — to a real Verifone terminal when
|
|
44
|
+
ready.** So Settings gets a **backend switcher**, not one hardcoded transport.
|
|
45
|
+
|
|
46
|
+
> **You wire the capability; the user enters the connection details.** You build the
|
|
47
|
+
> switcher, the IP field, and the credential storage, and ship sensible test
|
|
48
|
+
> defaults. You do NOT ask the user for an IP or password during this run — you
|
|
49
|
+
> describe how to use the screen in your end-of-run summary (Step 4).
|
|
50
|
+
|
|
51
|
+
The Windows 11 **demo app** (`Path-epos-demo-sdk-Windows11`) already implements this
|
|
52
|
+
exact pattern — its `SdkTerminalManager.BuildTerminal()` is the reference. Mirror it.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Step 0 — Reference the SDK (sibling-folder ProjectReference)
|
|
57
|
+
|
|
58
|
+
The SDK is consumed by relative `ProjectReference`, and the SDK repo must be cloned as
|
|
59
|
+
a **sibling** of this app (e.g. `..\..\..\Path-terminal-sdk-windows11`). Call
|
|
60
|
+
`get_code_example` with operation='install' and platform='windows'. Add these six
|
|
61
|
+
references to the app's `.csproj` (adjust the `..\` depth to your project's location):
|
|
62
|
+
|
|
63
|
+
```xml
|
|
64
|
+
<ItemGroup>
|
|
65
|
+
<ProjectReference Include="..\..\..\Path-terminal-sdk-windows11\Path.Terminal.CoreModels\Path.Terminal.CoreModels.csproj" />
|
|
66
|
+
<ProjectReference Include="..\..\..\Path-terminal-sdk-windows11\Path.Terminal.Sdk\Path.Terminal.Sdk.csproj" />
|
|
67
|
+
<ProjectReference Include="..\..\..\Path-terminal-sdk-windows11\Path.Terminal.EmulatorAdapter\Path.Terminal.EmulatorAdapter.csproj" />
|
|
68
|
+
<ProjectReference Include="..\..\..\Path-terminal-sdk-windows11\Path.Terminal.MockAdapter\Path.Terminal.MockAdapter.csproj" />
|
|
69
|
+
<ProjectReference Include="..\..\..\Path-terminal-sdk-windows11\Path.Terminal.Diagnostics\Path.Terminal.Diagnostics.csproj" />
|
|
70
|
+
<!-- Verifone backend (Step 2c) — bundles the Verifone .NET binding. -->
|
|
71
|
+
<ProjectReference Include="..\..\..\Path-terminal-sdk-windows11\Path.Terminal.PsdkAdapter\Path.Terminal.PsdkAdapter.csproj" />
|
|
72
|
+
</ItemGroup>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
> **Bluetooth needs no manifest entry here.** The harness is an *unpackaged* WinUI 3
|
|
76
|
+
> app (`WindowsPackageType=None`), so BLE comes through the WinRT projections the
|
|
77
|
+
> EmulatorAdapter already uses — there is no `Package.appxmanifest` capability to add.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Your job — four steps, in this order
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### Step 1 — Disconnect the existing loopback wiring
|
|
86
|
+
|
|
87
|
+
The harness ships with a **loopback** adapter, `OCPayTerminalAdapter`, composed at the
|
|
88
|
+
app root (look in `App.xaml.cs` / `Services/AppServices.cs` for where the terminal
|
|
89
|
+
manager is built). **Read the actual code** — a comment is not proof.
|
|
90
|
+
|
|
91
|
+
Create a Path-backed terminal manager that builds `PathTerminal` from the selected
|
|
92
|
+
backend (mirror the demo's `SdkTerminalManager.BuildTerminal()`), and swap the app
|
|
93
|
+
composition to use it instead of the OCPay manager.
|
|
94
|
+
|
|
95
|
+
> Keep `OCPayTerminalAdapter` in the codebase (it is the shipped loopback default) —
|
|
96
|
+
> just stop composing it as the live adapter. Do not delete it.
|
|
97
|
+
|
|
98
|
+
**Also disable any auto-connect on launch** — the Path backends connect manually from
|
|
99
|
+
Settings, never automatically on start.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### Step 2 — Add a backend switcher to Settings
|
|
104
|
+
|
|
105
|
+
The harness already has a Settings page (look for `SettingsPage` / `SettingsViewModel`).
|
|
106
|
+
Add a **Path POS Adapter** section with a backend picker offering **three** backends.
|
|
107
|
+
**Call `get_code_example` with operation='backend-switch' and platform='windows' first**
|
|
108
|
+
and reproduce its `BuildTerminal` shape exactly:
|
|
109
|
+
|
|
110
|
+
| Backend | Transport | Adapter | Needs |
|
|
111
|
+
|---|---|---|---|
|
|
112
|
+
| **Emulator (Wi-Fi)** — *default* | TCP/IP | `new TcpPathTerminalAdapter(host, …)` | emulator IP |
|
|
113
|
+
| **Emulator (Bluetooth)** | BLE | `new BlePathTerminalAdapter(…)` | scan + connect |
|
|
114
|
+
| **Verifone** | TCP/IP (PSDK) | `new VerifonePsdkAdapter(config, …)` | terminal IP + stored login |
|
|
115
|
+
|
|
116
|
+
```csharp
|
|
117
|
+
public enum TerminalBackend { EmulatorWifi, EmulatorBle, Verifone } // EmulatorWifi = default
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Persist the selection and connection details** in the harness's settings store (the
|
|
121
|
+
demo uses a small `AppSettings` class writing JSON to
|
|
122
|
+
`%LOCALAPPDATA%\<App>\app.json`). Store: `Backend`, `EmulatorHost`, `VerifoneHost`,
|
|
123
|
+
`LoginUsername`, `LoginPassword`, `LoginShift`, `RefundPassword` — with test defaults
|
|
124
|
+
(`VerifoneHost` "192.168.1.88", username "user", password "password123", shift
|
|
125
|
+
"shift123") so a fresh clone connects without typing.
|
|
126
|
+
|
|
127
|
+
#### Step 2a — Emulator (Wi-Fi, the default) and Verifone — IP entry
|
|
128
|
+
|
|
129
|
+
For the two IP-addressed backends show a **host/IP text box** (label "Emulator IP" or
|
|
130
|
+
"Verifone terminal IP" by selection) and an **Apply & Connect** button. On connect,
|
|
131
|
+
build the matching adapter from the stored host, dispose the previous `PathTerminal`,
|
|
132
|
+
and build a new one (only **one** client per terminal / per emulator Wi-Fi session).
|
|
133
|
+
TCP and Verifone need no scan — `DiscoverDevicesAsync()` returns one synthetic device
|
|
134
|
+
for the host, so Apply & Connect connects directly.
|
|
135
|
+
|
|
136
|
+
#### Step 2b — Emulator (Bluetooth) — scan and connect
|
|
137
|
+
|
|
138
|
+
For the BLE backend keep a scan/connect flow: a **Scan** button → `DiscoverDevicesAsync()`
|
|
139
|
+
→ list devices → **Connect** → live connection state from the `Events` stream.
|
|
140
|
+
Marshal UI updates onto the WinUI UI thread (`DispatcherQueue.TryEnqueue`).
|
|
141
|
+
|
|
142
|
+
#### Step 2c — Verifone backend and stored credentials
|
|
143
|
+
|
|
144
|
+
Call `get_code_example` with operation='verifone-init' and platform='windows'.
|
|
145
|
+
Construct it from a `VerifoneTerminalConfig` built from the **stored** login — never
|
|
146
|
+
hardcode credentials inline:
|
|
147
|
+
```csharp
|
|
148
|
+
using Path.Terminal.PsdkAdapter;
|
|
149
|
+
var adapter = new VerifonePsdkAdapter(
|
|
150
|
+
new VerifoneTerminalConfig {
|
|
151
|
+
Host = settings.VerifoneHost,
|
|
152
|
+
Username = settings.LoginUsername,
|
|
153
|
+
Password = settings.LoginPassword,
|
|
154
|
+
Shift = settings.LoginShift,
|
|
155
|
+
RefundPassword = settings.RefundPassword,
|
|
156
|
+
},
|
|
157
|
+
log: Log);
|
|
158
|
+
```
|
|
159
|
+
Keep the Verifone login fields **separate** (their own stored keys + editable fields).
|
|
160
|
+
All terminals are treated as **generic Verifone** (same AGPA app, same PSDK
|
|
161
|
+
connect/login) — no per-terminal config beyond IP + login.
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
### Step 3 — Wire sale, refund and void through the Path SDK
|
|
166
|
+
|
|
167
|
+
Once Step 1 is done, the harness's existing payment flow calls the Path-backed manager.
|
|
168
|
+
Confirm the transaction methods map correctly:
|
|
169
|
+
- Call `get_code_example` operation='sale' (platform='windows') — handle `TransactionState.Approved`, `Declined`, `TimedOut`, `Failed`, default.
|
|
170
|
+
- Call `get_code_example` operation='refund' — pass `originalTransactionId` from the sale result.
|
|
171
|
+
- Call `get_code_example` operation='void' — full reversal; success state is `Reversed`.
|
|
172
|
+
- Amounts are **minor units** (`420` = £4.20). Never pass decimals.
|
|
173
|
+
- Catch `PathException` and check whether it is recoverable before retrying.
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
### Step 4 — Verify it works end to end
|
|
178
|
+
|
|
179
|
+
1. Confirm the app root composes the Path-backed manager, not `OCPayTerminalAdapter`.
|
|
180
|
+
2. **Prove on the emulator first (the default — Wi-Fi/IP):**
|
|
181
|
+
- Put the Path POS Emulator in Wi-Fi mode (Config → Connection); note the `IP:port`
|
|
182
|
+
on its welcome screen.
|
|
183
|
+
- Run the app → Settings → Path POS Adapter → **Emulator (Wi-Fi)** → type that IP →
|
|
184
|
+
**Apply & Connect**. Connection state should reach Connected.
|
|
185
|
+
- (Optionally prove **Emulator (Bluetooth)**: select it, **Scan**, **Connect**.)
|
|
186
|
+
3. Run a sale (amountMinor `100` = £1.00), present a card / tap the emulator's NFC tag,
|
|
187
|
+
verify `result.State == Approved`, `TransactionId` is non-null, and receipt data is
|
|
188
|
+
populated (`get_code_example` operation='receipt'). Run a refund and a void.
|
|
189
|
+
4. **Then prove the switch to Verifone:** select **Verifone**, enter the terminal IP and
|
|
190
|
+
confirm the stored login, **Apply & Connect** — the SDK runs the PSDK init + login and
|
|
191
|
+
the same flow runs against the real terminal, unchanged. One client per terminal —
|
|
192
|
+
disconnect any other POS first.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## SDK rules — always follow these
|
|
197
|
+
|
|
198
|
+
**ALWAYS:**
|
|
199
|
+
- Call `get_code_example` (platform='windows') before writing SDK code
|
|
200
|
+
- Use `TransactionRequest.Sale(...)` / `.Refund(...)` / `.Void(...)` factory methods
|
|
201
|
+
- Use `RequestEnvelope.Create(...)` — never build envelopes by hand
|
|
202
|
+
- For **refunds** the success state is the refunded/approved state, and for **voids** it is `Reversed` — not the sale's `Approved`
|
|
203
|
+
- Dispose the old `PathTerminal` before building a new one on a backend change
|
|
204
|
+
- Marshal UI updates from `Events` onto the WinUI UI thread (`DispatcherQueue.TryEnqueue`)
|
|
205
|
+
|
|
206
|
+
**NEVER:**
|
|
207
|
+
- Use a raw `TransactionRequest` constructor — use the factory methods
|
|
208
|
+
- Store or log card data (masked PAN only)
|
|
209
|
+
- Retry a financial operation without a fresh `RequestEnvelope` (new idempotency key)
|
|
210
|
+
- Leave `OCPayTerminalAdapter` composed as the live adapter — Path must be the live one
|
|
211
|
+
- Leave auto-connect-on-launch running
|
|
212
|
+
- Set `OnCardRead` / `OnAck` on an adapter — `PathTerminal` owns those
|
|
213
|
+
- Write "Pico W" anywhere
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## After making changes
|
|
218
|
+
|
|
219
|
+
Summarise each file changed and confirm Step 1 (the live adapter is now Path-backed).
|
|
220
|
+
|
|
221
|
+
Then give **tailored connect instructions** — the user enters the connection details, so
|
|
222
|
+
tell them exactly where you wired things in:
|
|
223
|
+
- The Settings section you added the backend switcher to
|
|
224
|
+
- How to connect to the emulator over **Wi-Fi/IP** (the default): which backend, where to
|
|
225
|
+
type the emulator's IP, which button connects
|
|
226
|
+
- How to connect over **Bluetooth** instead (Scan → Connect)
|
|
227
|
+
- How to **switch to Verifone** when ready: pick Verifone, enter the terminal IP, confirm
|
|
228
|
+
the stored login, connect
|
|
229
|
+
|
|
230
|
+
Keep it brief and concrete — the user should follow it without reading code.
|