JavaScript/TypeScript SDK for accepting stablecoin payments with MoneyMQ.
| Package | Description | Version |
|---|---|---|
| @moneymq/sdk | Core SDK for MoneyMQ API | |
| @moneymq/x402 | x402 payment protocol utilities | |
| @moneymq/better-auth | Better Auth plugin for MoneyMQ |
# Core SDK
npm install @moneymq/sdk
# x402 protocol support
npm install @moneymq/x402
# Better Auth plugin
npm install @moneymq/better-authimport { MoneyMQ } from '@moneymq/sdk';
const moneymq = new MoneyMQ({
endpoint: 'http://localhost:8488',
});
// Create a product
const product = await moneymq.catalog.create({
name: 'Pro Plan',
description: 'Full access to all features',
});
// Create a price
const price = await moneymq.catalog.prices.create({
product: product.id,
currency: 'USDC',
amount: 1000, // $0.001 USDC (in smallest units)
type: 'one_time',
});
// Create a checkout session
const session = await moneymq.payment.checkout.create({
lineItems: [{ price: price.id, quantity: 1 }],
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
});
console.log('Checkout URL:', session.url);import { payUpon402 } from '@moneymq/x402';
// Automatically handles 402 Payment Required responses
const response = await payUpon402(
() => fetch('https://api.example.com/premium-endpoint'),
walletClient, // Optional: for actual payments
);import express from 'express';
import { createX402Handler, requirePayment } from '@moneymq/x402';
const app = express();
// Full configuration
app.use('/api/premium', createX402Handler({
price: 100, // 0.0001 USDC
currency: 'USDC',
recipient: 'YourWalletAddress...',
onPayment: async (payment) => {
console.log(`Received payment from ${payment.payer}`);
},
}));
// Shorthand
app.get('/api/data', requirePayment({
amount: 50,
currency: 'USDC',
recipient: 'YourWalletAddress...',
}), (req, res) => {
res.json({ data: 'Premium content' });
});const moneymq = new MoneyMQ({
endpoint: string, // MoneyMQ API endpoint
secret?: string, // Optional: for authenticated requests
timeout?: number, // Request timeout (default: 30000ms)
});// Products (shorthand)
moneymq.catalog.list({ active?, limit?, startingAfter? })
moneymq.catalog.create({ name, description?, metadata? })
moneymq.catalog.retrieve(id)
moneymq.catalog.update(id, { name?, description?, active?, metadata? })
moneymq.catalog.delete(id)
// Prices
moneymq.catalog.prices.create({ product, currency, amount, type, recurring?, metadata? })
moneymq.catalog.prices.retrieve(id)
moneymq.catalog.prices.list({ product?, active?, limit? })// Checkout Sessions
moneymq.payment.checkout.create({ lineItems, successUrl, cancelUrl, customer?, metadata? })
moneymq.payment.checkout.retrieve(id)
// Payment Links
moneymq.payment.links.create({ lineItems, expiresAt?, metadata? })
moneymq.payment.links.retrieve(id)
moneymq.payment.links.deactivate(id)
// Customers
moneymq.payment.customers.create({ email, name?, metadata? })
moneymq.payment.customers.retrieve(id, { expand? })
moneymq.payment.customers.update(id, { email?, name?, metadata? })
moneymq.payment.customers.list({ email?, limit? })
// Payments
moneymq.payment.retrieve(id)
moneymq.payment.list({ customerId?, status?, limit?, startingAfter? })
// Payouts
moneymq.payment.payouts.create({ amount, currency, destination })
moneymq.payment.payouts.retrieve(id)
moneymq.payment.payouts.list({ status?, limit?, startingAfter? })
moneymq.payment.payouts.settings.retrieve()
moneymq.payment.payouts.settings.update({ destination?, schedule?, minimumAmount? })Wraps HTTP calls with automatic 402 Payment Required handling.
payUpon402<T>(
promiseOrFn: Promise<T> | (() => Promise<T>),
walletClient?: Signer | MultiNetworkSigner,
maxValue?: bigint, // Default: 0.1 USDC
config?: X402Config,
): Promise<T>Creates Express middleware for x402 payment handling.
createX402Handler({
price: number, // Amount in smallest units
currency: string, // e.g., 'USDC'
recipient: string, // Wallet address
network?: string, // Default: 'solana'
onPayment?: (payment) => void | Promise<void>,
})Creates a Stripe client with automatic x402 payment handling.
createStripeClient(
apiKey: string,
walletClient?: Signer | MultiNetworkSigner,
config?: Stripe.StripeConfig,
x402Config?: X402Config,
): Stripe# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Run tests with coverage
pnpm test:coverage
# Lint code
pnpm lint
# Format code
pnpm formatReleases are managed via GitHub Actions with npm Trusted Publishing.
All packages share the same version. When you bump the root version, all packages are automatically synced:
# Bump version (patch, minor, or major)
npm version patch
# Push the commit and tag
git push && git push --tagsThe npm version command automatically:
- Updates the root
package.jsonversion - Runs the sync script to update all packages in
packages/*/package.json - Creates a git commit and tag
- After pushing the version bump, go to GitHub Actions
- Click "Run workflow"
- Optionally enable "Dry run" to test without publishing
- Click "Run workflow" to start the release
The workflow will:
- Build and test all packages
- Validate version consistency across packages
- Create a git tag (if not already created)
- Publish
@moneymq/sdkand@moneymq/x402to npm with provenance - Create a GitHub Release with auto-generated release notes
See CONTRIBUTING.md for guidelines.
MIT - see LICENSE for details.