better-auth-streampay is a community-developed plugin designed to seamlessly integrate StreamPay payment and subscription functionalities into applications utilizing the `better-auth` authentication framework. Currently at version 1.0.0, this package provides robust features such as checkout integration with lazy consumer creation, a comprehensive customer portal for managing subscriptions and invoices, and secure handling of StreamPay webhooks with HMAC-SHA256 signature verification. It also allows for optional eager consumer provisioning upon user signup and ensures consumer data synchronization on user updates or deletions. The plugin differentiates itself by offering a tightly coupled solution specifically for StreamPay users within the Better Auth ecosystem, providing distinct sub-plugins for various functionalities like `checkout`, `portal`, `subscriptions`, and `webhooks` for modular integration. While there's no fixed release cadence, being a v1.0.0 community plugin, updates are typically driven by feature development and bug fixes.
npm install better-auth-streampayVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the server-side setup of the `better-auth-streampay` plugin, configuring the core `streampay` plugin with its sub-plugins: `checkout`, `portal`, `subscriptions`, and `webhooks`. It initializes the StreamPay SDK client and integrates webhook handlers for payment success and subscription cancellation events.
Be aware of the support channel distinction. For core StreamPay service issues, contact StreamPay support. For plugin integration issues, open an issue on the plugin's GitHub repository.
Ensure all peer dependencies are installed correctly and meet the specified version ranges, e.g., `pnpm add better-auth-streampay @streamsdk/typescript better-auth zod`.
Define all required environment variables in your `.env` file or deployment configuration, ensuring `STREAMPAY_API_KEY` is correctly Base64-encoded.
Execute the appropriate database migration command for your ORM/CLI after installation (e.g., `npx @better-auth/cli migrate`, `npx drizzle-kit generate && npx drizzle-kit migrate`, or `npx prisma migrate dev`).
Add `STREAMPAY_API_KEY=your_base64_encoded_api_key` to your `.env` file or environment variables.
Ensure `@streamsdk/typescript` is installed via `pnpm add @streamsdk/typescript` and imported correctly as `import StreamSDK from '@streamsdk/typescript';`.
Ensure sub-plugins are correctly composed within the `use` array: `streampay({ client: streamPayClient, use: [checkout(...), portal()] })`.Verify that `STREAMPAY_WEBHOOK_SECRET` in your environment exactly matches the webhook secret configured in your StreamPay dashboard.