# Invoice Detail

Displays detailed information about a specific invoice, including line items, amounts, and due date.

***

## Usage

```typescript
const invoiceDetail = client.components.invoiceDetail({
  containerId: 'invoice-detail',
  invoiceId: 'inv_xxx',
  onPayNow: (invoice) => {
    console.log('Pay now clicked for:', invoice.id);
  },
  onBack: () => {
    console.log('Back clicked');
  },
});
```

***

## Configuration

### InvoiceDetailConfig

| Property      | Type                         | Required | Description                      |
| ------------- | ---------------------------- | -------- | -------------------------------- |
| `containerId` | `string`                     | Yes      | ID of the container element      |
| `invoiceId`   | `string`                     | Yes      | Invoice ID to display            |
| `theme`       | `ThemeConfig`                | No       | Custom theme configuration       |
| `onPayNow`    | `(invoice: Invoice) => void` | No       | Called when "Pay Now" is clicked |
| `onBack`      | `() => void`                 | No       | Called when "Back" is clicked    |
| `onError`     | `(error: Error) => void`     | No       | Called on fetch errors           |

***

## Features

The Invoice Detail component displays:

* Invoice number with download button
* Customer information
* Due date and status
* Line items with descriptions and amounts
* Subtotal, taxes, and total amount
* Payment scheduling option (if applicable)

***

## Example

```html
<div id="invoice-detail"></div>

<script type="module">
  import { AlternativeClient } from '@getalternative/partner-sdk';

  const client = new AlternativeClient({
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
  });

  // Get invoice ID from URL
  const invoiceId = new URLSearchParams(window.location.search).get('id');

  const detail = client.components.invoiceDetail({
    containerId: 'invoice-detail',
    invoiceId: invoiceId,
    onPayNow: (invoice) => {
      // Navigate to payment selection
      window.location.href = `/pay?invoice=${invoice.id}`;
    },
    onBack: () => {
      window.history.back();
    },
  });
</script>
```

***

## Invoice Download

The component includes a download button next to the invoice number that allows users to download the invoice as a PDF.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.alternativepayments.io/web-sdk/components/invoice-detail.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
