SDK Purchase Flow
Your own agent can search, browse, and reason independently, then call MagicPay SDK to resolve Memory data or execute a Memory-managed payment action.
When To Use The SDK
Use the SDK when your application already owns the surrounding agent, browser, worker, or MCP tool and needs a typed MagicPay client for sessions, requests, data resolution, and actions.
Flow
The external agent reaches the Memory-managed payment point, then hands off only the Memory-managed step to MagicPay.
- Create or reuse a MagicPay workflow session.
- Create a data, action, or choice request with a stable client request id.
- Wait for user approval or supplied data.
- Use the returned artifact only at the trusted browser or provider boundary.
- Resume the agent workflow after MagicPay reports the result.
Minimal SDK Shape
A typical purchase uses sessions, data resolution, action execution, and result waiting.
const { session } = await client.sessions.create({ type: 'payment' }); // The agent never sees raw data; it asks for a value or a use-approval.const handle = await client.memory.createRequest(session.id, input);const result = await client.memory.waitForResult(session.id, handle);