Invoices and Payments represent revenue collected by your business customers. This can be in-person sales made through a point of sale system, invoices sent through your software, ecommerce sales, or any other type of accounts receivable activity.

To import invoices, make a call to the Create Invoice endpoint. This endpoint takes in the data on the sale your customer made, what was sold, any associated taxes, and how the sale was paid for.

Invoices without payments

Invoices can be created without any payments associated with them. Payments towards the invoice can then be recorded later on using the Record an Invoice Payment endpoint.

Request
curl -X POST https://sandbox.layerfi.com/v1/businesses/{business_id}/invoices \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "external_id": "019234",
    "sent_at": "2024-04-02T09:02:00Z",
    "due_at": "2023-04-02T09:02:00Z",
    "invoice_number": "1",
    "recipient_name": "John Doe",
    "line_items": [
      {
        "product": "Cleaner Solution Pro",
        "unit_price": 1299,
        "quantity": 2,
        "sales_taxes": [
          {
            "tax_account": {
              "type": "Tax_Name",
              "name": "CALIFORNIA_VAT"
            },
            "amount": 218
          }
        ]
      },
      {
        "product": "Full drain cleaning service",
        "unit_price": 25000,
        "quantity": 1
      }
    ],
    "additional_discount": 250
  }'

The API will respond with an Invoice object.

Response
{
  "data": {
    "type": "Invoice",
    "id": "6d0c298f-3e4e-4538-9a71-1d5359c22f71",
    "business_id": "83d8fb80-31ee-4d57-b684-44b4aaa5e01f",
    "external_id": "019234",
    "status": "SENT",
    "sent_at": "2024-04-02T09:02:00Z",
    "due_at": "2023-04-02T09:02:00Z",
    "paid_at": null,
    "voided_at": null,
    "invoice_number": "1",
    "recipient_name": "John Doe",
    "line_items": [
      {
        "id": "e6a491dd-9c22-4403-a54f-32d741a7ec67",
        "invoice_id": "6d0c298f-3e4e-4538-9a71-1d5359c22f71",
        "account_identifier": null,
        "description": null,
        "product": "Cleaner Solution Pro",
        "unit_price": 1299,
        "quantity": "2.00",
        "subtotal": 2598,
        "discount_amount": 0,
        "sales_taxes_total": 218,
        "sales_taxes": [
          {
            "tax_account": {
              "type": "Tax_Name",
              "name": "CALIFORNIA_VAT"
            },
            "amount": 218
          }
        ],
        "total_amount": 2816
      },
      {
        "id": "44f06385-3ef5-4517-8095-eeedaf2054ab",
        "invoice_id": "6d0c298f-3e4e-4538-9a71-1d5359c22f71",
        "account_identifier": null,
        "description": null,
        "product": "Full drain cleaning service",
        "unit_price": 25000,
        "quantity": "1.00",
        "subtotal": 25000,
        "discount_amount": 0,
        "sales_taxes_total": 0,
        "total_amount": 25000
      }
    ],
    "subtotal": 27598,
    "additional_discount": 250,
    "additional_sales_taxes_total": 0,
    "tips": 0,
    "total_amount": 27566,
    "outstanding_balance": 27566,
    "payment_allocations": [],
    "imported_at": "2024-04-19T02:23:59.902537Z",
    "updated_at": null,
    "transaction_tags": []
  }
}

Invoices with payments

For instances where invoices are immediately paid, such as when using a point of sale device for in-person sales or online merchandise sales, you can also include payment information directly in the creation of the invoice. This looks very similar to the above example with the addition of payment information.

Request
curl -X POST https://sandbox.layerfi.com/v1/businesses/863ed926-e30d-40f4-8e7e-b0d5387ce4fb/invoices \
  -H "Authorization: Bearer <access_token>" \
  -H "Content-Type: application/json" \
  -d '{
    "external_id": "234988",
    "sent_at": "2024-05-12T14:13:07Z",
    "due_at": "2024-06-12T14:13:07Z",
    "invoice_number": "2",
    "recipient_name": "John Doe",
    "line_items": [
      {
        "product": "Cleaner Solution Pro",
        "unit_price": 1299,
        "quantity": 1,
        "sales_taxes": [
          {
            "amount": 114
          }
        ]
      },
      {
        "product": "Cleanout snake",
        "unit_price": 18000,
        "quantity": 1
      }
    ],
    "additional_sales_taxes": [
      {
        "amount": 1291
      }
    ],
    "payments": [
      {
        "external_id": "239872",
        "method": "CREDIT_CARD",
        "amount": 20704,
        "processor": "MY_PROCESSOR"
      }
    ]
  }'

In this case, the API will respond with the same created invoice, but with the invoice marked as fully or partially paid and the payment information included.

Response
{
  "data": {
    "type": "Invoice",
    "id": "d01c9839-0378-4d44-b409-a0ae1e5dbb59",
    "business_id": "83d8fb80-31ee-4d57-b684-44b4aaa5e01f",
    "external_id": "234988",
    "status": "PAID",
    "sent_at": "2024-05-12T14:13:07Z",
    "due_at": "2024-06-12T14:13:07Z",
    "paid_at": "2024-04-19T02:24:00.009658Z",
    "voided_at": null,
    "invoice_number": "2",
    "recipient_name": "John Doe",
    "line_items": [
      {
        "id": "fd60aa16-a0a6-40de-a814-b01836acfd36",
        "invoice_id": "d01c9839-0378-4d44-b409-a0ae1e5dbb59",
        "account_identifier": null,
        "description": null,
        "product": "Cleaner Solution Pro",
        "unit_price": 1299,
        "quantity": "1.00",
        "subtotal": 1299,
        "discount_amount": 0,
        "sales_taxes_total": 114,
        "sales_taxes": [
          {
            "tax_account": {
              "type": "Legder_Account_Id",
              "id": "ba1a5e91-d04a-4c67-919e-f09a20d6e151"
            },
            "amount": 114
          }
        ],
        "total_amount": 1413
      },
      {
        "id": "4dd7708a-cad4-46e6-b5ff-34248a0b141e",
        "invoice_id": "d01c9839-0378-4d44-b409-a0ae1e5dbb59",
        "account_identifier": null,
        "description": null,
        "product": "Cleanout snake",
        "unit_price": 18000,
        "quantity": "1.00",
        "subtotal": 18000,
        "discount_amount": 0,
        "sales_taxes_total": 0,
        "total_amount": 18000
      }
    ],
    "subtotal": 19299,
    "additional_discount": 0,
    "additional_sales_taxes_total": 1291,
    "additional_sales_taxes": [
      {
        "tax_account": {
          "type": "Legder_Account_Id",
          "id": "ba1a5e91-d04a-4c67-919e-f09a20d6e151"
        },
        "amount": 1291
      }
    ],
    "tips": 0,
    "total_amount": 20704,
    "outstanding_balance": 0,
    "payment_allocations": [
      {
        "invoice_id": "d01c9839-0378-4d44-b409-a0ae1e5dbb59",
        "payment_id": "4d769e05-a101-4a16-8de5-6c37fbcec088",
        "amount": 20704,
        "transaction_tags": []
      }
    ],
    "imported_at": "2024-04-19T02:24:00.009658Z",
    "updated_at": null,
    "transaction_tags": []
  }
}