Menu

Add payments to a Next.js app with two route handlers (merchant of record, tax handled)
πŸ“°

Add payments to a Next.js app with two route handlers (merchant of record, tax handled)

DEV Community: nextjsΒ·Panche I.Β·about 15 hours ago
#2Sbd551F
#devtonextjs#devto#dev#agentaos#route
Reading 0:00
15s threshold

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_...…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.