Skip to main content

Monetization Enhancement — Quick Start

Enable and troubleshoot monetization in ValkyrAI/ValorIDE. Start with the API client, then layer in advanced features.

Critical Path — Must Do First

1. Create Missing API Client

File: ValorIDE/src/services/monetization/api.ts

import axios, { AxiosInstance, AxiosError } from "axios";

class MonetizationApiClient {
private client: AxiosInstance;

constructor() {
const baseURL = process.env.VALKYR_API_URL || "http://localhost:8080";
this.client = axios.create({
baseURL,
timeout: 30000,
headers: { "Content-Type": "application/json" },
// JWT interceptor
this.client.interceptors.request.use((config) => {
title: "Monetization Enhancement — Quick Start"
description: "Enable and troubleshoot monetization in ValkyrAI/ValorIDE. Start with the API client, then layer in advanced features."
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
return config;
});
// Error interceptor
this.client.interceptors.response.use(
(response) => response,
(error: AxiosError<any>) => {
if (error.response?.status === 403) {
throw new Error(
`[UPGRADE_REQUIRED] ${
error.response.data?.message || "Higher tier required"
}`
);
}
if (error.response?.status === 422) {
throw new Error(
`[VALIDATION] ${error.response.data?.message || "Invalid input"}`
);
}
if (error.response?.status === 404) {
throw new Error(
`[NOT_FOUND] ${error.response.data?.message || "Not found"}`
);
}
throw error;
}
);
}
}

Next Steps

  • Add amazement features (see full guide)
  • Test all monetization endpoints
  • Monitor for errors and upgrade requirements

See also: Stripe Inline Payment Plan