Skip to main content

1) Run the CLI setup

From your project root:
npx solvapay init
This command authenticates you, writes SOLVAPAY_SECRET_KEY, installs core packages, and prints a starter snippet. See CLI setup for full details.

2) Protect your first endpoint (Express)

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,
      },
    }
  }),
)
Test it:
curl -X POST http://localhost:3000/tasks \
  -H "Content-Type: application/json" \
  -H "x-customer-ref: user_123" \
  -d '{"title":"My first task"}'

3) Continue by framework

Next steps