{"_id":"@100pay-hq/pay402","_rev":"2-689491a691bebf8cb544fd69d08c028e","name":"@100pay-hq/pay402","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@100pay-hq/pay402","version":"1.0.0","keywords":["pay402","x402","paywall","agentic commerce","ai agent","payment","crypto","express","middleware"],"author":"","license":"ISC","_id":"@100pay-hq/pay402@1.0.0","maintainers":[{"name":"brainyjosh","email":"joshuabrendan5@gmail.com"},{"name":"miracleio","email":"miracleficient@gmail.com"}],"dist":{"shasum":"447c20e2018045e9d8b72704a4d4fbdf024f754e","tarball":"https://registry.npmjs.org/@100pay-hq/pay402/-/pay402-1.0.0.tgz","fileCount":7,"integrity":"sha512-OBE6oVKNj4+1Uzaf8c6wYUZ2uesLoYjCbi6gVQ1bsV0Wb6WGnZsNt314Yih390eiTygpIix/XbHfBmolX2bC7A==","signatures":[{"sig":"MEUCIGaFIxdRVR3oEz5Qq0fElQHTIyDcp4vYCylCHlBcIz7hAiEAuw3r8FsKYGujymeghD8tp3UPgJBdAHJQYuKSG7MiWMk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":35867},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"cc054284c4491f13790ed0026ef791b97014cafc","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc","prepublishOnly":"npm run build"},"_npmUser":{"name":"brainyjosh","email":"joshuabrendan5@gmail.com"},"_npmVersion":"11.6.2","description":"PAY402 payment protocol middleware for Express","directories":{},"_nodeVersion":"25.1.0","dependencies":{"axios":"^1.6.5","x402-express":"^0.7.1"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.3.3","@types/node":"^20.11.0","@types/express":"^4.17.21"},"_npmOperationalInternal":{"tmp":"tmp/pay402_1.0.0_1763669184383_0.34023618504881137","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@100pay-hq/pay402","version":"2.0.0","description":"PAY402 payment protocol middleware for Express","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","test":"echo \"Error: no test specified\" && exit 1","prepublishOnly":"npm run build"},"keywords":["pay402","x402","paywall","agentic commerce","ai agent","payment","crypto","express","middleware"],"author":{"name":"brainyjosh"},"license":"ISC","devDependencies":{"@types/express":"^4.17.21","@types/node":"^20.11.0","typescript":"^5.3.3"},"dependencies":{"axios":"^1.6.5","x402-express":"^0.7.1"},"gitHead":"564996ca00b19759d4a03bccc1bdd5f97b023088","_id":"@100pay-hq/pay402@2.0.0","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-YVhlwyxA6KIKuH1cdMF4ZPV+PydL9Ndy1mVoajuRJHvKQfprrbsYG1KB0BPcVkcP7CbyEtVe6Ut8VrTIg+C2oQ==","shasum":"14be55124253d3d4e63a850fef007ceae8cd2da8","tarball":"https://registry.npmjs.org/@100pay-hq/pay402/-/pay402-2.0.0.tgz","fileCount":7,"unpackedSize":37422,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBKpvL05j7Xjw7ukSCvZ3Dgaf9+UZFo6g3LZHqP0WO7rAiAMkF3CGug/qU9VpmEzKTuzzxaxvJqp3CdHimdeeRW2jw=="}]},"_npmUser":{"name":"miracleio","email":"miracleficient@gmail.com"},"directories":{},"maintainers":[{"name":"brainyjosh","email":"joshuabrendan5@gmail.com"},{"name":"miracleio","email":"miracleficient@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pay402_2.0.0_1781817315084_0.39011489768193286"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-20T20:06:24.271Z","modified":"2026-06-18T21:15:15.438Z","1.0.0":"2025-11-20T20:06:24.575Z","2.0.0":"2026-06-18T21:15:15.284Z"},"license":"ISC","keywords":["pay402","x402","paywall","agentic commerce","ai agent","payment","crypto","express","middleware"],"description":"PAY402 payment protocol middleware for Express","maintainers":[{"name":"brainyjosh","email":"joshuabrendan5@gmail.com"},{"name":"miracleio","email":"miracleficient@gmail.com"}],"readme":"# [PAY402](https://402.finance)\n\n[PAY402](https://402.finance) is a payment protocol middleware for Express that integrates with the x402 protocol by Coinbase. It enables gas-free crypto and stablecoin payments for your API routes, settling directly to your bank account via 100Pay.\n\n## Features\n\n- **Gas-free Payments**: Supports payments across 8 blockchains.\n- **Automatic Settlement**: Payments are settled in stablecoins or fiat to your bank account.\n- **Express Middleware**: Easy integration with existing Express applications.\n- **Bulk Route Upload**: Automatically uploads your route configurations to the NanoApps Store, making it discoverable to nanochat and other ai agents like claude, chatgpt, gemini, cursur, kiro, antigravity, codex, etc.\n- **Smart Caching**: Only uploads route configurations when changes are detected, optimizing startup time.\n- **TypeScript Support**: Written in TypeScript with full type definitions.\n\n## Installation\n\n```bash\nnpm npm i @100pay-hq/pay402 x402-express\n```\n\n## Usage\n\n### 1. Configuration\n\nCreate a configuration object for your application. You'll need credentials from your NanoApps console and 100Pay dashboard.\n\n```typescript\nimport express from 'express';\nimport { withPay402 } from '@100pay-hq/pay402';\n\nconst app = express();\n\nconst nanoAppConfig = {\n    nanoAppId: \"your-nanoapp-id\", // From NanoApps console\n    nanoAppSecret: \"your-nanoapp-secret\", // From NanoApps console\n    _100PayApiKey: \"your-100pay-api-key\", // From 100Pay dashboard\n    wallet: \"0xYourWalletAddress\", // Your 100Pay checkout wallet (EVM or Solana)\n    facilitator: {\n        url: \"https://x402.org/facilitator\", // Optional x402 facilitator endpoint\n        apiKey: \"your-facilitator-api-key\" // Optional\n    },\n    network: \"base\", // e.g., \"base\", \"solana\"\n    routes: [\n        {\n            name: \"Search Products\",\n            description: \"Search for products in the catalog.\",\n            path: \"/api/search\",\n            method: \"GET\",\n            pricing: \"fixed\",\n            price: async (req) => {\n                return {\n                    amount: \"1\",\n                    currency: \"USD\",\n                    symbol: \"$\"\n                };\n            }\n        },\n        {\n            name: \"Pay for Order\",\n            description: \"Pay for a specific order.\",\n            path: \"/api/pay-for-order\",\n            method: \"POST\",\n            pricing: \"dynamic\",\n            price: async (req) => {\n                // Access route parameters via req.route.params\n                // const orderId = req.route.params.order_id;\n                return {\n                    amount: \"20\",\n                    currency: \"NGN\",\n                    symbol: \"N\"\n                };\n            }\n        }\n    ]\n};\n\n// Apply the middleware\napp.use(withPay402(nanoAppConfig));\n\n// Define your actual routes\napp.get('/api/search', (req, res) => {\n    res.json({ data: \"Search results...\" });\n});\n\napp.post('/api/pay-for-order', (req, res) => {\n    res.json({ status: \"Order paid!\" });\n});\n\napp.listen(3000, () => {\n    console.log('Server running on port 3000');\n});\n```\n\n### 2. Route Configuration\n\nEach route in the `routes` array must have the following properties:\n\n- `name`: Human-readable name of the tool/route.\n- `description`: Description for AI agents or users.\n- `path`: The Express route path (e.g., `/api/users/:id`).\n- `method`: HTTP method (`GET`, `POST`, `PUT`, `DELETE`, etc.).\n- `pricing`: `'fixed'` or `'dynamic'`.\n- `price`: An async function that returns the price object `{ amount, currency, symbol }`. It receives a context object containing `body`, `route` (params, query, path), and `headers`.\n\n### 3. Payment Verification\n\nThe middleware automatically handles:\n1.  Intercepting requests to configured routes.\n2.  Calculating the price (converting to PAY/USDC if needed).\n3.  Returning a 402 Payment Required response with payment options if no payment is provided.\n4.  Verifying the `x-pay402` header with 100Pay.\n5.  Attaching the payment receipt to `req.payment_receipt`.\n\n## License\n\nISC\n","readmeFilename":"README.md","author":{"name":"brainyjosh"}}