> This page is for Developer.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.bigcommerce.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.bigcommerce.com/_mcp/server.

# Payments and Receipts

Plan: B2B Developer

Lesson 15 of 18 · 30 min

## Introduction

The final key aspect of the B2B storefront purchasing experience is the ability to inspect a company's invoice payments.

B2B Edition contains two related entities: payments and receipts. The "receipt" records attached to payments contain the most granular details about the payment transactions.

## Fetching Payments

Fetch a list of the current company's invoice payments with the `invoicePayments` query.

### Example query and response:

#### Query

```graphql showLineNumbers={false}
query GetPayments {
    invoicePayments {
        pageInfo {
            hasNextPage
            hasPreviousPage
            startCursor
            endCursor
        }
        totalCount
        edges {
            node {
                id
                createdAt
                totalCode
                totalAmount
                payerName
                processingStatus
                companyId
                companyName
                paymentReceiptSet {
                    edges {
                        node {
                            id
                            createdAt
                            customerId
                            totalCode
                            totalAmount
                            payerName
                            paymentId
                            paymentType
                            receiptLineSet {
                                edges {
                                    node {
                                        id
                                        createdAt
                                        customerId
                                        receiptId
                                        paymentId
                                        invoiceId
                                        invoiceNumber
                                        amount
                                        paymentType
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```

#### Response

```json showLineNumbers={false}
{
    "data": {
        "invoicePayments": {
            "pageInfo": {
                "hasNextPage": true,
                "hasPreviousPage": false,
                "startCursor": "YXJy...",
                "endCursor": "YXJy..."
            },
            "totalCount": 25,
            "edges": [
                {
                    "node": {
                        "id": "223344",
                        "createdAt": 1726078850,
                        "totalCode": "USD",
                        "totalAmount": "500.0000",
                        "payerName": "John Doe",
                        "processingStatus": 3,
                        "companyId": "1112233",
                        "companyName": "John's Widgets",
                        "paymentReceiptSet": {
                            "edges": [
                                {
                                    "node": {
                                        "id": "334455",
                                        "createdAt": 1726078850,
                                        "customerId": 1112233,
                                        "totalCode": "USD",
                                        "totalAmount": "500.0000,
                                        "payerName": "John Doe",
                                        "paymentId": 223344,
                                        "paymentType": "Offline",
                                        "receiptLineSet": {
                                            "edges": [
                                                {
                                                    "node": {
                                                        "id": "445566",
                                                        "createdAt": 1726078850,
                                                        "customerId": 1112233,
                                                        "receiptId": 334455,
                                                        "paymentId": 223344,
                                                        "invoiceId": 556679,
                                                        "invoiceNumber": "0556679",
                                                        "amount": {
                                                            "code": "USD",
                                                            "value": "500.0000"
                                                        },
                                                        "paymentType": "Offline"
                                                    }
                                                }
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                },
                {
                    "node": {
                        "id": "223343",
                        ...
                        "paymentReceiptSet": {
                            "edges": [
                                {
                                    "node": {
                                        "id": "334454",
                                        ...
                                        "totalAmount": "175.0000",
                                        ...
                                        "paymentId": 223343,
                                        "paymentType": "visa ending in 1111",
                                        "receiptLineSet": {
                                            "edges": [
                                                {
                                                    "node": {
                                                        "id": "445565",
                                                        ...
                                                        "receiptId": 334454,
                                                        "paymentId": 223343,
                                                        "invoiceId": 5556677,
                                                        "invoiceNumber": "05556677",
                                                        "amount": {
                                                            "code": "USD",
                                                            "value": "100.0000"
                                                        },
                                                        "paymentType": "visa ending in 1111"
                                                    }
                                                },
                                                {
                                                    "node": {
                                                        "id": "445564",
                                                        ...
                                                        "receiptId": 334454,
                                                        "paymentId": 223343,
                                                        "invoiceId": 5556678,
                                                        "invoiceNumber": "05556678",
                                                        "amount": {
                                                            "code": "USD",
                                                            "value": "75.0000"
                                                        },
                                                        "paymentType": "visa ending in 1111"
                                                    }
                                                }
                                            ]
                                        }
                                    }
                                }
                            ]
                        }
                    }
                },
                ...
            ]
        }
    }
}
```

* `invoicePayments` supports standard pagination arguments, as do `paymentReceiptSet` and `receiptLineSet`, which are also standard cursor lists.
* Other supported filtering arguments include `invoiceId`, `dateCreatedBeginAt`, and `dateCreatedEndAt`. The date-related filter arguments accept a date string like "2025-01-01".
* Note in the response above that a payment contains a `paymentReceiptSet`, while each payment receipt contains a `receiptLineSet`. In the above example, the first payment included only a single receipt line for a single invoice (0556679). The second payment in the results included two receipt lines, as payment was made against two different invoices (05556677 and 05556678).
* The payment records include basic transaction details like `totalAmount`, while the receipt and receipt line records include further details such as the `paymentType`. In the above example, the first payment in the results was an "offline" payment applied manually to an invoice, while the second payment was captured via credit card from a BigCommerce checkout and order, resulting in the `paymentType`"visa ending in 1111".
* In the above example, note that in the second payment, the individual invoice amounts are queried in the receipt lines ($100 and $75), while the total payment amount of \$175 is expressed in `totalAmount` on the payment record.
* The `customerId` field on receipt and receipt line records contains the company's ID.
* The `processingStatus` of a payment will be 1 if the payment is "Awaiting Processing", 2 for "Processing", 3 for "Completed", and 4 for "Refunded." Recall that the processing status of each payment will affect the `pendingPaymentCount` of the associated invoices.

Note that while `invoicePayments` can be filtered on an invoice ID, the results returned will still include the full receipt details for the payments. Remember that a payment can potentially include multiple invoices, so filtering on an invoice ID is not a guarantee that the resulting payment details will be relevant only to that invoice.

For this reason, the most common use case for this query is when you want to present a storefront user with full details of their payment transactions, rather than payments by invoice.

### Fetching a Single Payment

The `invoicePayment` query can be used to fetch a single payment using its ID. This query returns the same GraphQL type as the nodes returned from `invoicePayments`, so the same fields can be queried.

#### Example Request:

```graphql showLineNumbers={false}
query GetPayment(
    $paymentId: Int!
) {
    invoicePayment(
        paymentId: $paymentId
    ) {
        id
        createdAt
        totalCode
        totalAmount
        ...
        paymentReceiptSet {
            edges {
                node {
                    id
                    createdAt
                    customerId
                    totalCode
                    totalAmount
                    ...
                    receiptLineSet {
                        edges {
                            node {
                                id
                                createdAt
                                customerId
                                receiptId
                                paymentId
                                invoiceId
                                ...
                            }
                        }
                    }
                }
            }
        }
    }
}
```

## Fetching Receipt Lines

As mentioned above, payments can potentially include amounts applied to multiple invoices. In contexts where you want to present storefront users with the payment details relevant only to a specific invoice, it's useful to be able to query receipt lines directly.

The `allReceiptLines` query can be used to fetch a list of receipt line records and can be filtered on a specific invoice ID. The results returned are of the same GraphQL type as the list items a `receiptLineSet` seen above, so the same fields can be queried.

### Example query, variables, and response:

#### Query

```graphql showLineNumbers={false}
query GetReceiptLines(
    $invoiceId: String
) {
    allReceiptLines(
        invoiceId: $invoiceId
    ) {
        pageInfo {
            hasNextPage
            hasPreviousPage
            startCursor
            endCursor
        }
        totalCount
        edges {
            node {
                id
                createdAt
                customerId
                receiptId
                paymentId
                invoiceId
                invoiceNumber
                amount
                paymentStatus
                paymentType
            }
        }
    }
}
```

#### Variables

```json showLineNumbers={false}
{
    "invoiceId": "5556677"
}
```

#### Response

```json showLineNumbers={false}
{
    "data": {
        "allReceiptLines": {
            "pageInfo": {
                "hasNextPage": false,
                "hasPreviousPage": false,
                "startCursor": "YXJy...",
                "endCursor": "YXJy..."
            },
            "totalCount": 1,
            "edges": [
                {
                    "node": {
                        "id": "445565",
                        "createdAt": 1725979982,
                        "customerId": 1112233,
                        "receiptId": 334454,
                        "paymentId": 223343,
                        "invoiceId": 5556677,
                        "invoiceNumber": "05556677",
                        "amount": {
                            "code": "USD",
                            "value": "100.0000"
                        },
                        "paymentStatus": 2,
                        "paymentType": "visa ending in 1111"
                    }
                }
            ]
        }
    }
}
```

The above example relates to the previous example response for `invoicePayments`. Note that the single returned result was part of a payment that included receipt lines for two separate invoices. But since this `allReceiptLines` query is filtered on a specific invoice ID, only the relevant line is returned.

The `paymentStatus` field on a receipt line should match the `processingStatus` of its payment.

### Fetching a Single Receipt Line

The `receiptLine` query will fetch the details of a single receipt line, using its ID. This returns the same GraphQL type as each node returned from `allReceiptLines`, so the same fields can be queried.

#### Example Request:

```graphql showLineNumbers={false}
query GetReceiptLine(
    $id: Int!
) {
    receiptLine(
        id: $id
    ) {
        id
        createdAt
        customerId
        receiptId
        paymentId
        invoiceId
        invoiceNumber
        amount
        paymentStatus
        paymentType
    }
}
```

## Fetching Receipts

There are available `receipts` and `receipt` queries for fetching receipt records specifically. However, these queries are generally redundant with fetching payments, since there is almost always a single receipt associated with a payment, receipt details can already be queried directly under payments, and `receipts` can't be filtered on the same arguments (like invoice ID). Directly querying payments or receipt lines should serve the various use cases of your storefront applications.