import type { PlatformClient } from "./client"; import type { X402PaymentRequest, X402PaymentResult } from "./types"; /** * API for making x402 payments to access paid workflows. * * The x402 protocol allows workflows to be monetized - users pay to trigger them. * This API provides methods to pay for and execute x402-protected workflows programmatically. * * @example * ```typescript * const client = new PlatformClient(); * * // Pay and execute an x402 workflow by ID - only wallet key needed! * const result = await client.payments.payWorkflow({ * workflowId: 123, * input: { prompt: 'Hello world' } * }); * * console.log(result.response); // Workflow response * ``` */ export declare class PaymentsAPI { private client; constructor(client: PlatformClient); /** * Pay for and execute an x402-protected workflow. * * This method handles the entire x402 payment flow automatically: * 1. Resolves the x402 trigger URL (from workflowId or provided triggerUrl) * 2. Creates a payment-enabled fetch wrapper using your wallet * 3. Makes a request to the trigger URL * 4. Automatically handles the 402 Payment Required response * 5. Signs and submits the payment * 6. Retries the request with payment proof * 7. Returns the workflow response * * Provide either `workflowId` (recommended) or `triggerUrl`. * * @param params - Payment parameters * @param params.workflowId - The workflow ID (recommended - resolves x402 trigger URL automatically) * @param params.triggerUrl - The x402 trigger URL (alternative to workflowId) * @param params.privateKey - Wallet private key for payment (or uses WALLET_PRIVATE_KEY env var) * @param params.input - Input data to pass to the workflow * @returns Payment result with workflow response * * @example * ```typescript * // By workflow ID (recommended) * const result = await client.payments.payWorkflow({ * workflowId: 123, * input: { prompt: 'Generate a summary' } * }); * * console.log(result.response); // Workflow execution result * ``` * * @example * ```typescript * // By direct URL * const result = await client.payments.payWorkflow({ * triggerUrl: 'https://api.openserv.ai/webhooks/x402/trigger/abc123', * input: { prompt: 'Generate a summary' } * }); * ``` * * @example * ```typescript * // Explicitly providing private key * const result = await client.payments.payWorkflow({ * workflowId: 123, * privateKey: '0x...', * input: { query: 'What is the weather?' } * }); * ``` */ payWorkflow(params: X402PaymentRequest): Promise; /** * Resolve the x402 trigger URL from workflowId or return the provided triggerUrl. */ private resolveX402TriggerUrl; /** * Discover available x402 services from the platform. * * Lists all public x402-enabled workflows that can be paid for and executed. * Each service includes pricing, input schema, and the webhook URL to call. * * @returns Array of available x402 services * * @example * ```typescript * const services = await client.payments.discoverServices(); * * for (const service of services) { * console.log(`${service.name}: $${service.x402Pricing}`); * console.log(`URL: ${service.webhookUrl}`); * } * ``` */ discoverServices(): Promise>; /** * Get preflight information for an x402 trigger. * * Returns pricing, input schema, and wallet information for a trigger * before making a payment. Useful for displaying payment UI. * * @param params - Parameters object * @param params.token - The trigger token (from the webhook URL path) * @returns Trigger preflight information including pricing and schema * * @example * ```typescript * // Extract token from webhook URL: .../trigger/{token} * const preflight = await client.payments.getTriggerPreflight({ * token: 'abc123def456' * }); * * console.log(`Price: ${preflight.x402Pricing}`); * console.log(`Pay to: ${preflight.x402WalletAddress}`); * ``` */ getTriggerPreflight(params: { token: string; }): Promise<{ triggerId: string; triggerName: string; triggerDescription: string | null; jsonSchema: Record; uiSchema: Record; x402Enabled: boolean; x402Pricing: string; x402WalletAddress: string; erc8004AgentId: string | null; }>; } //# sourceMappingURL=payments-api.d.ts.map