API
Learn the public Paymesh surface, the contracts it exposes, and the boundaries between core, providers, adapters, databases, and plugins.
Surface area
The public API is intentionally small.
At the top level, paymesh exports:
createClientdefineProviderdefinePlugindefineDatabaseAdapterresolveDatabaseSchemaeventlazyrequestwithRaw- all public client, provider, database, plugin, and error types
createClient
createClient is the composition point for the entire runtime.
import { createClient } from "paymesh";
import { postgres } from "@paymesh/postgres";
import { stripe } from "@paymesh/stripe";
export const paymesh = createClient({
provider: stripe({
secret: "sk_test_123",
webhookSecret: "whsec_123",
}),
database: postgres("postgres://postgres:postgres@localhost:5432/paymesh"),
includeRaw: false,
plugins: [],
});It accepts:
provider- optional
database - optional
schema - optional
plugins - optional
includeRaw
Sub-clients
The client managers exposed today are:
paymentscouponspixcustomerswebhooksroutesplugins
Plugins may add more client surface through extends().
payments.create() now also accepts:
couponCode?allowCouponCodes?
Providers that advertise coupons expose:
coupons.create()coupons.get()coupons.list()coupons.update()coupons.activate()coupons.deactivate()coupons.delete()coupons.archive()coupons.check()
Coupon lifecycle helpers now have distinct semantics:
archive()keeps the coupon mapped locally and marks it unusabledelete()removes the coupon from the provider when supported and marks the local mapping as deleted
Capability model
Providers declare capabilities instead of pretending every provider is equivalent.
Known capability keys include:
pixcouponscheckoutsubscriptionswebhooksrefundscustomerPortalcustomers
That is why application code can ask what a provider supports instead of probing behavior implicitly.
Event model
Webhook delivery is normalized into Paymesh event types such as:
payment.createdpayment.succeededpayment.failedpayment.canceledpayment.refundedcoupon.createdcoupon.updatedcoupon.deletedcoupon.archivedcoupon.redeemedcoupon.redemption_failedcoupon.expiredcustomer.createdcustomer.updatedcustomer.deletedsubscription.createdsubscription.updatedsubscription.canceledcheckout.completed
Provider packages map their own raw event names into these normalized events.
Extension model
Paymesh is not closed around its own first-party surface. Plugins can contribute:
- routes
- middleware
- schema extensions
- custom events
- client extensions
- setup logic
That is why the public API includes definePlugin, event, and lazy.