Access and review your past invoices and payment records.
AI Docs provides a comprehensive overview of your billing information, including a detailed history of your payments. This feature allows you to easily track your past transactions, understand your spending, and access important financial documents like invoices directly from your dashboard.
AI Docs integrates with a third-party payment provider (Dodo) to securely manage subscriptions and process payments. When you view your billing page, AI Docs retrieves your payment history directly from this provider, ensuring that the information displayed is always up-to-date and accurate.
The process involves your request going through the AI Docs backend, which then communicates with the payment provider's API. The relevant payment data is fetched, filtered to show only your transactions, and then presented in your dashboard.
You can access your payment history by navigating to your Dashboard and selecting the Billing section. On this page, alongside your current subscription details and usage statistics, you will find a dedicated section for your recent payments.
For each transaction, AI Docs displays the following key details:
completed, failed, pending).card, paypal).AI Docs typically displays your 10 most recent payments. For more details on managing your subscription status, refer to Managing Your Subscription.
For developers looking to integrate AI Docs billing information into their own systems or to retrieve payment history programmatically, AI Docs provides a dedicated API endpoint.
GET /api/billing/payments
This endpoint allows authenticated users to retrieve a list of their recent payment transactions. It fetches data from the integrated payment provider, filters it by the user's customer ID, and returns a structured array of payment objects.
This endpoint is protected and requires user authentication. Requests must be made by a logged-in user, typically handled automatically by the AI Docs client-side application.
The API returns a JSON object containing an array of payment records. Each record includes details such as the payment ID, amount, currency, status, payment method, creation date, and a URL to the invoice.
// Example response structure
{
"payments": [
{
"id": "pay_xxxxxxxxxxxxxxxxx",
"amount": 2900,
"currency": "usd",
"status": "completed",
"method": "card",
"createdAt": "2024-01-15T10:00:00Z",
"invoiceUrl": "https://invoices.paymentprovider.com/inv_xxxxxxxxxxxxxxxxx"
},
// ... up to 9 more recent payments
]
}
You can fetch your payment history using a standard HTTP GET request. In a client-side application, this might look like:
// Example of fetching payment history from a client-side application
async function fetchPaymentHistory() {
try {
const response = await fetch('/api/billing/payments');
if (!response.ok) {
// Handle non-successful responses, e.g., authentication error
console.error('Failed to fetch payment history:', response.statusText);
return [];
}
const data = await response.json();
console.log('Your payment history:', data.payments);
return data.payments;
} catch (error) {
console.error('An error occurred while fetching payment history:', error);
return [];
}
}
// Call the function to retrieve payments
fetchPaymentHistory();