paiment does not receive your payment-processor webhooks. Your server handles
checkout and subscription events, then calls the SDK to sync billing state.
// After your billing provider confirms a new subscription
await paiment.subscriptions.create({
userId: user.id,
externalPlanId: plan.id,
planName: 'Pro',
price: 2999,
currency: 'USD',
interval: 'monthly',
source: 'billing-webhook',
});
API reference
subscriptions
Method
Description
create
New subscription (+ user if needed)
list
List by userId, status
get
Get by subscription id
update
Patch price, status, dates
end
Close subscription period
cancel
End immediately
usage
Method
Description
report
Record input/output tokens, provider, model
list
List usage rows
users
Method
Description
create
Shortcut: user + subscription
get
By your external userId
list
List users, filter by plan
update
Partial update
delete
Delete user
plans
Method
Description
create / list / get / update / delete
Plan catalog CRUD
Key fields
Field
Meaning
userId
Your identifier for the end-user
externalPlanId
Your plan key (required on plans, subscriptions, users, usage)
planName
Optional display name; naming hint when auto-creating a plan