purchase_get
Retrieve detailed information about a specific purchase, including product details, status, transactions, customer data, and subscription information by providing the purchase ID.
Instructions
Get detailed information about a specific purchase.
Returns complete purchase details including:
Product information
Purchase status
Associated transactions
Customer information
Subscription details (if applicable)
Required: purchaseId parameter
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| purchaseId | Yes | Unique identifier of the purchase |
Implementation Reference
- src/tools/purchases.ts:145-152 (handler)Handler for 'purchase_get' tool: calls this.api.getPurchase(args.purchaseId) and returns the purchase details as JSON text content.
case 'purchase_get': const purchase = await this.api.getPurchase(args.purchaseId, { appName: args.appName }); return { content: [{ type: "text", text: JSON.stringify(purchase, null, 2) }] }; - src/tools/purchases.ts:66-92 (schema)Schema definition for 'purchase_get' tool: defines name, description, and inputSchema with required purchaseId (string) and optional appName for master key users.
{ name: "purchase_get", description: `Get detailed information about a specific purchase. - Returns complete purchase details including: - Product information - Purchase status - Associated transactions - Customer information - Subscription details (if applicable) - Required: purchaseId parameter${appNameRequired ? '\n- Requires appName parameter when using master key' : ''}`, inputSchema: { type: "object", properties: { purchaseId: { type: "string", description: "Unique identifier of the purchase" }, ...(appNameRequired ? { appName: { type: "string", description: "Name of the app to fetch data from. Required when using master key." } } : {}) }, required: appNameRequired ? ["purchaseId", "appName"] : ["purchaseId"] } } - src/iaptic-api.ts:190-193 (helper)Low-level API method getPurchase(): makes a GET request to /purchases/{purchaseId} and returns the response data.
async getPurchase(purchaseId: string, params?: { appName?: string }) { const response = await this.client.get(`/purchases/${purchaseId}`, { params }); return response.data; } - src/server.ts:84-125 (registration)Registration: server.ts routes tool calls with name prefix 'purchase_' to PurchaseTools.handleTool(), which dispatches to the 'purchase_get' case.
// Handle tool calls this.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { // Route tool calls to appropriate handler if (name.startsWith('customer_')) { return await this.tools.customers.handleTool(name, args); } if (name.startsWith('purchase_')) { return await this.tools.purchases.handleTool(name, args); } if (name.startsWith('transaction_')) { return await this.tools.transactions.handleTool(name, args); } if (name.startsWith('stats_')) { return await this.tools.statistics.handleTool(name, args); } if (name.startsWith('stripe_')) { return await this.tools.stripe.handleTool(name, args); } if (name.startsWith('event_')) { return await this.tools.events.handleTool(name, args); } if (name.startsWith('iaptic_')) { return await this.tools.app.handleTool(name, args); } throw new Error(`Unknown tool: ${name}`); } catch (error: unknown) { const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred'; console.error(`Error handling tool ${name}:`, errorMessage); if (error instanceof Error && error.stack) { console.error(error.stack); } return { isError: true, content: [{ type: "text", text: `Error: ${errorMessage}` }] }; } });