newOS for Developers
Back to Payment Hub
Subscription Check
beginnerVerify Pro status and subscription level from the current user.
Endpoint
GET /user/currentReturns the authenticated user's private profile including subscription fields.
Response Schema
interface UserReadPrivateResponse {
id: string;
username: string;
displayName?: string;
// Subscription fields
isPro: boolean; // Has active Pro subscription
proLevel?: number; // Pro tier level (1, 2, 3)
subscriptionLevel?: string; // "free" | "pro" | "enterprise"
subscriptionStatus?: string; // "active" | "canceled" | "past_due"
subscriptionExpiry?: string; // ISO date string
stripeUid?: string; // Stripe customer ID
// Credits
watts: number; // Engagement credits balance
}Implementation
import { current, execProgressiveHandler } from "newgraph-signals";
// Get current user with subscription status
const user = await execProgressiveHandler(current);
// Check subscription status
if (user.isPro) {
console.log("Pro user, level:", user.proLevel);
console.log("Expires:", user.subscriptionExpiry);
} else {
console.log("Free tier, WATTS:", user.watts);
}
// Paywall example
const canAccessPremiumFeature = () => {
return user.isPro || user.subscriptionLevel === "enterprise";
};Paywall Pattern
// React component pattern
function FeatureGate({ children, requiredLevel = 1 }) {
const { user } = useAuth();
if (!user?.isPro || (user?.proLevel || 0) < requiredLevel) {
return <UpgradePrompt requiredLevel={requiredLevel} />;
}
return children;
}
// Usage
<FeatureGate requiredLevel={2}>
<PremiumAnalyticsDashboard />
</FeatureGate>Edge Cases
past_due — User has payment issues but may still have access during grace period
canceled — Access continues until subscriptionExpiry date
No stripeUid — User never had a subscription, only has free tier