# Invoice methods: bill, collect, refund, void

URL: /code/sdk/invoice/verbs · Id: `page:code/sdk/invoice/verbs`

> The Invoice Verbs bill, collect, refund, void as typed SDK methods, with inputs, result, refusals and an example.

Reference for [Invoice](/business/nouns/invoice), one group of [Invoice methods](/code/sdk/invoice).

### Invoice.bill
Bill finalizes an Invoice and presents it to the Customer for payment. [Verb page](/business/nouns/invoice/bill?interface=sdk).

```ts
interface InvoiceVerbs {
  bill(input: InvoiceBillInput, options?: SB.CallOptions): SB.Call<Invoice>
}
```

Emits [`Invoice.billed`](/business/events/Invoice.billed).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `invoice` | [Invoice](/business/nouns/invoice) | Yes | The draft Invoice. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `invoice` | [Invoice](/business/nouns/invoice) | Yes | The open Invoice. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

```ts
import { $ } from 'startup-builder'

const invoice = await $.Invoice.bill({ invoice: 'inv_KjgRxmhMzZ' })
```

### Invoice.collect
Collect charges a Customer’s saved payment method for an open Invoice and retries on failure. [Verb page](/business/nouns/invoice/collect?interface=sdk).

```ts
interface InvoiceVerbs {
  collect(input: InvoiceCollectInput, options?: SB.CallOptions): SB.Call<Invoice>
}
```

Emits [`Invoice.collected`](/business/events/Invoice.collected).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `invoice` | [Invoice](/business/nouns/invoice) | Yes | The open Invoice. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `invoice` | [Invoice](/business/nouns/invoice) | Yes | The paid Invoice. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The operation is part of an Offer the caller has not accepted or paid for. | [`payment-required`](/code/api/errors/payment-required) | Accept the Offer named in the response, then retry the call. | [Offer.accept](/business/nouns/offer/accept) |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

```ts
import { $ } from 'startup-builder'

const invoice = await $.Invoice.collect({ invoice: 'inv_FXANyzQojc' })
```

### Invoice.refund
Refund returns all or part of a paid Invoice to the Customer’s original payment method and posts the reversing Entries. [Verb page](/business/nouns/invoice/refund?interface=sdk).

```ts
interface InvoiceVerbs {
  refund(input: InvoiceRefundInput, options?: SB.CallOptions): SB.Call<Invoice>
}
```

Emits [`Invoice.refunded`](/business/events/Invoice.refunded).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `invoice` | [Invoice](/business/nouns/invoice) | Yes | The paid Invoice. |
| `amount` | `money` | No | The amount. Defaults to the full payment; pro rata takes the unused part of the Period. |
| `reason` | `text` | Yes | Why the money goes back, kept on the Invoice. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `invoice` | [Invoice](/business/nouns/invoice) | Yes | The Invoice, with its refunded amount. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| A Dispute on the Invoice is open | [`refused`](/code/api/errors/refused) | Clear what the check names, then call it again. | None. |

**Example**

```ts
import { $ } from 'startup-builder'

const invoice = await $.Invoice.refund({ invoice: 'inv_9sfvgeRT7L', reason: 'Example reason' })
```

### Invoice.void
Void cancels an unpaid Invoice, keeps it on record, and posts the reversing Entries. [Verb page](/business/nouns/invoice/void?interface=sdk).

```ts
interface InvoiceVerbs {
  void(input: InvoiceVoidInput, options?: SB.CallOptions): SB.Call<Invoice>
}
```

Emits [`Invoice.voided`](/business/events/Invoice.voided).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `invoice` | [Invoice](/business/nouns/invoice) | Yes | The unpaid Invoice. |
| `reason` | `text` | Yes | Why the amount is no longer due. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `invoice` | [Invoice](/business/nouns/invoice) | Yes | The voided Invoice, kept forever. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| The record changed since it was read, so the write would overwrite a newer version. | [`conflict`](/code/api/errors/conflict) | Read the record again, then retry the write against its current state. | None. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

```ts
import { $ } from 'startup-builder'

const invoice = await $.Invoice.void({ invoice: 'inv_KjgRxmhMzZ', reason: 'Example reason' })
```