Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 4 additions & 72 deletions app/api/v1/paid/[product]/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { NextRequest, NextResponse } from 'next/server';
import { getSeedProduct, paymentRequirement } from '@/lib/seed-products';
import { buildSeedProductPayload } from '@/lib/seed-product-intelligence';
import { verifyPyrimidPaymentTx } from '@/lib/payment-verification';

function paymentRequired(req: NextRequest, product: NonNullable<ReturnType<typeof getSeedProduct>>) {
Expand All @@ -24,77 +25,6 @@ function paymentRequired(req: NextRequest, product: NonNullable<ReturnType<typeo
);
}

function payload(productId: string, req: NextRequest, proof: string) {
const query = Object.fromEntries(req.nextUrl.searchParams.entries());

switch (productId) {
case 'mya-agent-enrichment': {
const agent = query.agent || 'demo-agent';
return {
enrichment: {
agent,
category: 'developer-tools',
agent_readable_summary: `${agent} can monetize API calls by exposing paid tools through x402 and listing them in the Pyrimid catalog.`,
monetization_angle: 'Package one high-value tool as a paid MCP/API endpoint priced $0.05-$0.25 per call.',
suggested_cta: 'Claim listing → add paid tool → route purchases through Pyrimid.',
},
};
}
case 'mya-category-scout': {
const category = query.category || 'developer-tools';
return {
category,
agents: [
{ name: 'MCP server vendors', fit: 'high', reason: 'Already expose tool interfaces; easiest path to paid tools.' },
{ name: 'AI API wrappers', fit: 'high', reason: 'Usage-based value maps cleanly to x402 per-call pricing.' },
{ name: 'agent directories', fit: 'medium', reason: 'Can route discovery traffic into paid vendor listings.' },
],
};
}
case 'vendor-lead-discovery': {
const segment = query.segment || 'mcp';
return {
segment,
leads: [
{ segment: 'mcp', target: 'MCP servers with paid/data-heavy tools', pitch: 'Add optional x402 payment gate + Pyrimid catalog listing.' },
{ segment: 'agent-frameworks', target: 'Agent frameworks with marketplace/plugin systems', pitch: 'Let builders sell tools to agents with Base USDC settlement.' },
{ segment: 'api-tools', target: 'AI API services with per-call cost', pitch: 'Turn API calls into agent-purchasable products.' },
],
};
}
case 'mcp-server-audit': {
const url = query.url || 'https://example.com/mcp';
return {
audit: {
url,
recommended_paid_tools: ['search', 'enrich', 'export', 'analyze'],
pricing: '$0.01-$0.25 per call depending on compute/data cost',
integration_steps: [
'Add 402 response with x402 accepts[] metadata',
'Register vendor/product in Pyrimid catalog',
'Expose tool schema in MCP server card',
'Add affiliateBps for distribution agents',
],
},
};
}
case 'x402-integration-plan': {
const service = query.service || 'agent-api';
return {
plan: {
service,
route_shape: 'GET /api/paid/{tool} returns 402 until X-PAYMENT or X-PAYMENT-TX is supplied',
payment_network: 'Base USDC',
pyrimid_metadata: ['vendorId', 'productId', 'affiliateBps', 'endpoint', 'output_schema'],
launch_checklist: ['publish llms.txt', 'publish agents.txt', 'submit MCP server card', 'list product in Pyrimid catalog'],
},
};
}
default:
return { result: 'unknown_seed_product' };
}
}

export async function GET(req: NextRequest, context: { params: Promise<{ product: string }> }) {
const { product: productId } = await context.params;
const product = getSeedProduct(productId);
Expand Down Expand Up @@ -122,13 +52,15 @@ export async function GET(req: NextRequest, context: { params: Promise<{ product
);
}

const payload = await buildSeedProductPayload(product.product_id, Object.fromEntries(req.nextUrl.searchParams.entries()));

return NextResponse.json({
product_id: product.product_id,
vendor_id: product.vendor_id,
payment_tx: verification.txHash,
payment_amount: verification.amount?.toString(),
buyer: verification.buyer,
...payload(product.product_id, req, proof),
...payload,
routed_by: 'pyrimid',
links: {
docs: 'https://pyrimid.ai/quickstart',
Expand Down
Loading