# B2B invoice billing

## Overview

B2B invoice billing lets your business customers pay for Entur orders by invoice. The invoice is issued and managed by Two, Entur's invoice provider. As a partner, you control when the invoice is created and, optionally, how multiple orders are bundled into a single invoice.

There are two invoice types:

- **TWO_B2B**: one invoice per order, issued immediately when you create it (given that the buyer completes verification).
- **TWO_B2B_CONSOLIDATED**: the invoice is created with status `PENDING` (also dependent on verification) and not issued until you explicitly bundle it with other drafts into a consolidated invoice. Use this when you want to collect several orders and send one invoice to the buyer.

The invoice type is determined from the payment type of the associated payment transaction.

## Before you begin

To use B2B invoice billing, you need to:

- Be an Entur partner with access to the partner sales APIs.
- Get your authentication credentials (see [Authentication](/docs/partner-services/authentication)).
- Contact Team Betaling to have B2B invoice billing enabled for your organisation.

## 1. Create an order

A B2B invoice is always tied to an Entur order. Use the [Sales Platform](/guides/sales-v2/make-first-purchase) to create and confirm an order for the products your customer is purchasing. Keep the order ID returned when the order is confirmed, as you will need it in every subsequent step.

The order total is the amount you can check against the company's credit limit in the next step and what the invoice will be issued for.

## 2. (Optional) Check credit

Before creating a transaction with a B2B invoice type, you can check whether a company is approved for invoice purchases and what their available credit limit is. The credit check goes through our invoice provider, and company details are looked up from Brønnøysundregistrene using the organisation number (9 digits, starting with 8 or 9). If the company is not found, check the organisation number and try again. If the order amount exceeds the company's available credit or the credit check is declined by another reason, the invoice provider will reject the invoice creation (step 4). Checking up front is therefore recommended.

Compare the order total from step 1 against `availableLimit` and `perOrderLimit` before proceeding.

::endpoint[invoice-partner/getCreditCheck]


## 3. Create a payment with the invoice type

Create a payment and add a transaction with the invoice type you want to use: `TWO_B2B` or `TWO_B2B_CONSOLIDATED`. The invoice service reads the payment type from the transaction when you create the invoice in the next step, so the payment type on the transaction determines which invoicing mode is used.

```mermaid
sequenceDiagram
    participant P as Partner backend
    participant PA as Payments API

    P->>PA: Create payment
    PA-->>P: paymentId
    P->>PA: Add transaction (paymentType: TWO_B2B or TWO_B2B_CONSOLIDATED)
    PA-->>P: transactionId
```

::endpoint[payment-partner/createPayment]

::endpoint[payment-partner/addTransaction]

Keep both `paymentId` and `transactionId`, as you will need them in the next step.

## 4. Create the B2B invoice

Create the invoice by calling the Invoice API with the order ID, the payment ID and transaction ID from the previous step, a redirectUrl, the company's organisation number, and the buyer's contact information. Optionally include a department, project, or reference to have them printed on the invoice.

The `redirectUrl` is where the buyer returns after completing or cancelling the invoice provider's verification step.

```mermaid
sequenceDiagram
    participant P as Partner backend
    participant IA as Invoice API

    P->>IA: Create B2B invoice (orderId, paymentId, transactionId, redirectUrl, organisationNumber, buyerInfo)
    IA-->>P: invoiceId + paymentUrl
```

::endpoint[invoice-partner/createB2bInvoice]

The response contains:

| Field | Description                                                                                                                                                                        |
| --- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `invoiceId` | Entur's internal ID for the invoice. Used to look up the invoice and fetch the PDF. For `TWO_B2B_CONSOLIDATED`, this is also the ID you pass when creating a consolidated invoice. |
| `paymentUrl` | URL the buyer must navigate to in order to verify the purchase. By default present for both invoice types.                                                                         |

## 5. Redirect the buyer to verify

For both invoice types, the buyer must verify the purchase by navigating to the `paymentUrl`. Send the buyer to this URL and wait for them to return to your `redirectUrl`.

The `paymentUrl` leads to a Two-hosted page where the buyer's representative completes a verification step. Two determines the verification method dynamically based on risk assessment, typically a one-time code sent by SMS or email, or identification through Vipps. Once verified, payment is captured, the order is confirmed, and tickets are issued.
If the buyer does not complete verification within 48 hours, Two cancels the order automatically. The invoice remains in status `PENDING` and no payment is captured.

```mermaid
sequenceDiagram
    participant B as Buyer
    participant P as Partner app
    participant IA as Invoice API
    participant T as Two (invoice provider)

    P->>B: Redirect to paymentUrl
    B->>T: Complete verification (one-time code or Vipps)
    B->>P: Return to redirectUrl
    P->>IA: Get invoice (optional — check status)
    IA-->>P: status INVOICED or AWAITING_CONSOLIDATION
```

What happens with the invoice after verification depends on the invoice type:

- **TWO_B2B**: the invoice is issued immediately and moves to status `INVOICED`.
- **TWO_B2B_CONSOLIDATED**: the invoice moves to status `AWAITING_CONSOLIDATION` and is not issued until you create a consolidated invoice (step 6).


:::note
Unless a separate arrangement has been made with Entur and Two, buyer verification is required for all B2B invoice purchases.
:::

## 6. Create a consolidated invoice (TWO_B2B_CONSOLIDATED)

For `TWO_B2B_CONSOLIDATED`, the invoice is a draft after creation and is not issued to the buyer (it will have status `PENDING` or `AWAITING_CONSOLIDATION`, depending on whether it is verified or not). When you are ready to invoice the buyer — for example at the end of a billing period — collect the invoice IDs you want to bundle and create a consolidated invoice. All invoices in the request must belong to the same company, be in status `AWAITING_CONSOLIDATION` and not already be part of another consolidated invoice.

The consolidated invoice is issued immediately and cannot be undone.

```mermaid
sequenceDiagram
    participant P as Partner backend
    participant IA as Invoice API
    participant T as Two (invoice provider)

    P->>IA: Create consolidated invoice (invoiceIds, optional reference)
    IA->>T: Issue consolidated invoice
    T-->>IA: success
    IA-->>P: consolidatedInvoiceId
```

::endpoint[invoice-partner/createConsolidatedInvoice]

## Invoice status

You can fetch a B2B invoice at any time to check its current status and inspect its lines and fees.

::endpoint[invoice-partner/getB2bInvoice]

| Status | Applies to | Meaning                                                                         |
| --- | --- |---------------------------------------------------------------------------------|
| `PENDING` | Both | Invoice created; waiting for buyer verification.                                |
| `INVOICED` | `TWO_B2B` | The buyer has verified and the invoice is issued.                               |
| `AWAITING_CONSOLIDATION` | `TWO_B2B_CONSOLIDATED` | The invoice is ready to be included in a consolidated invoice.                  |
| `CONSOLIDATED` | `TWO_B2B_CONSOLIDATED` | The invoice has been included in a consolidated invoice and issued to the buyer. |
| `PARTIALLY_CREDITED` | Both | One or more lines have been refunded.                                           |
| `CREDITED` | Both | The invoice has been fully refunded.                                            |

## Downloading the PDF

A `TWO_B2B` invoice has its own PDF, available once the invoice reaches `INVOICED` status. A `TWO_B2B_CONSOLIDATED` invoice has no individual PDF; download the PDF from the consolidated invoice instead.

PDFs are available in Norwegian (`nb_NO`), English (`en_US`), and Swedish (`sv_SE`). The language defaults to Norwegian.

::endpoint[invoice-partner/getB2bInvoicePdf]

::endpoint[invoice-partner/getConsolidatedInvoicePdf]

## Next steps

You made it! Here is what you can do next:

- Read the full [Invoice Partner API reference](/apis/invoice-partner) to explore all available endpoints, including searching invoices and downloading PDFs.
