Selling a SaaS plan or a digital product from a Next.js app usually means two jobs: taking the payment, and then handling VAT, sales tax and invoices for buyers in other countries. This post sets up both in two route handlers with @agentaos/nextjs . AgentaOS is a merchant of record: it sells the product in its own name, charges the buyer's VAT or sales tax, issues the invoice and pays you out.
You need:
a Next.js app with the App Router
an AgentaOS account (test mode works from the first minute)
a product created in the AgentaOS dashboard, and its link ID from the product page
1. Install and set the keys
npm install @agentaos/nextjs
Enter fullscreen mode
Exit fullscreen mode
In the dashboard, create an API key under Developers β API keys ( sk_test_... in test mode). Under Settings β Developers β Webhooks , set the URL to https://your-domain.com/api/webhooks/agentaos and copy the signing secret.
# .env.local AGENTAOS_API_KEY = sk_test_...β¦