Billing
Manage billing plans, subscriptions, checkout sessions, and usage.
const urblock = new Urblock("sk_test_...");
listPlans()
List all available billing plans with pricing.
const plans = await urblock.billing.listPlans();
for (const plan of plans.data) {
console.log(`${plan.name}: $${plan.price_monthly / 100}/mo — ${plan.tx_limit} tx/mo`);
}
Returns: ListResponse<PlanResponse>
createCheckout(params)
Create a Stripe Checkout session for plan upgrade.
const session = await urblock.billing.createCheckout({
plan: "pro",
interval: "yearly",
});
// Redirect user to Stripe
window.location.href = session.url;
| Param | Type | Required | Description |
|---|---|---|---|
plan | string | Yes | starter, pro, or business |
interval | string | No | monthly (default) or yearly |
Returns: CheckoutSessionResponse
createCryptoCheckout(params)
Create a crypto payment request (USDT/USDC).
const checkout = await urblock.billing.createCryptoCheckout({
plan: "pro",
currency: "USDC",
chain: "polygon",
});
console.log(`Send ${checkout.amount} ${checkout.currency} to ${checkout.wallet_address}`);
| Param | Type | Required | Description |
|---|---|---|---|
plan | string | Yes | starter, pro, or business |
interval | string | No | monthly or yearly |
currency | string | No | USDT or USDC |
chain | string | No | polygon, ethereum, arbitrum, base |
Returns: CryptoCheckoutResponse
getCryptoPaymentStatus(paymentId)
Check the status of a crypto payment.
const payment = await urblock.billing.getCryptoPaymentStatus("pay_abc123");
console.log(`Status: ${payment.status}`);
Returns: PaymentResponse
getSubscription()
Get the current tenant subscription.
const sub = await urblock.billing.getSubscription();
console.log(`Plan: ${sub.plan}, Status: ${sub.status}`);
Returns: SubscriptionResponse
createPortal()
Create a Stripe Customer Portal session for managing payment methods and invoices.
const portal = await urblock.billing.createPortal();
window.location.href = portal.url;
Returns: PortalSessionResponse
listInvoices(params?)
List Stripe invoices for the tenant.
const invoices = await urblock.billing.listInvoices({ limit: 20 });
for (const inv of invoices.data) {
console.log(`${inv.id}: $${inv.amount_paid / 100} — ${inv.status}`);
}
| Param | Type | Required | Description |
|---|---|---|---|
limit | number | No | 1–100 (default: 10) |
Returns: ListResponse<InvoiceItem>
listPayments(params?)
List billing payment history (crypto + manual).
const payments = await urblock.billing.listPayments({ status: "confirmed" });
for (const p of payments.data) {
console.log(`${p.id}: ${p.amount} ${p.currency} — ${p.status}`);
}
| Param | Type | Required | Description |
|---|---|---|---|
limit | number | No | 1–100 (default: 20) |
status | string | No | pending, confirmed, expired |
Returns: ListResponse<PaymentResponse>
getUsage()
Get current billing usage for the tenant.
const usage = await urblock.billing.getUsage();
const pct = Math.round((usage.tx_count / usage.tx_limit) * 100);
console.log(`Usage: ${usage.tx_count}/${usage.tx_limit} (${pct}%)`);
Returns: UsageResponse
See Also
- Billing API — full endpoint reference
- Rate Limiting — rate limit behavior per plan