1) Run the CLI setup
From your project root:SOLVAPAY_SECRET_KEY, installs core packages, and
prints a starter snippet.
See CLI setup for full details.
Set up with CLI and protect your first endpoint in minutes.
npx solvapay init
SOLVAPAY_SECRET_KEY, installs core packages, and
prints a starter snippet.
See CLI setup for full details.
import express from 'express'
import { createSolvaPay } from '@solvapay/server'
const app = express()
app.use(express.json())
const solvaPay = createSolvaPay()
const payable = solvaPay.payable({
product: 'prd_YOUR_PRODUCT',
plan: 'pln_YOUR_PLAN',
})
app.post(
'/tasks',
payable.http(async req => {
return {
success: true,
task: {
title: req.body.title,
},
}
}),
)
curl -X POST http://localhost:3000/tasks \
-H "Content-Type: application/json" \
-H "x-customer-ref: user_123" \
-d '{"title":"My first task"}'