Invoices

Manage invoices, track payment status, and handle the complete invoice lifecycle in FarPay. This section covers creating, updating, and monitoring invoices with their payment states.

Overview

Invoices represent bills sent to customers for payment. Each invoice has a payment state that tracks its progress through the payment lifecycle, from creation to completion or failure.

Invoice Payment States

StateValueDescription
Not Paid100Initial state when invoice is created
Paid200Payment received and matches invoice amount
Scheduled300Customer has agreement, payment scheduled
Pending400Scheduled payment being processed
Rejected500Payment rejected by user, creditor, or financial institution
Chargeback600Amount charged back, transaction reversed
Payment Failed700Payment failed due to agreement removal or low balance
N/A1000System errors or payment system errors
Invoice State Diagram

API Endpoints

Get All Invoices

Retrieve all invoices with optional filtering.

GET https://api.farpay.io/v2/invoices

Query Parameters:

  • fromDueDate (optional) - Filter from due date (YYYY-MM-DD)
  • toDueDate (optional) - Filter to due date (YYYY-MM-DD)
  • paymentStatus (optional) - Filter by payment status (100, 200, 300, 400, 500, 600, 700)

Response Example:

[
  {
    "Id": 123,
    "Created": "2025-09-15T10:30:00Z",
    "InvoiceNumber": "INV-001",
    "PaymentDueDate": "2025-09-15T00:00:00Z",
    "InvoiceAmount": 125.00,
    "ToBePaidAmount": 125.00,
    "PaymentReferenceStatus": "Ok",
    "PaymentType": "MobilePayInvoice",
    "SendStatus": "Queue",
    "ErrorDescription": ""
  }
]

Get Single Invoice

Retrieve detailed information for a specific invoice.

GET https://api.farpay.io/v2/invoices/{invoiceId}

Parameters:

  • invoiceId (path) - The invoice's unique identifier

Response Example:

{
  "Send": {
    "SentDate": "0001-01-01T00:00:00",
    "ErrorCode": 0,
    "ErrorDescription": "",
    "Channel": "",
    "Status": "Queue",
    "ScheduleSendDate": null,
    "ToAddress": "",
    "Note": ""
  },
  "Id": 74836045,
  "Token": "wN0BNaBoW2DMfx5DeVasQMgs508JbuO8",
  "PaymentDetails": "+71 <000004561237944 +42426240<",
  "MarkedAsPaid": null,
  "Created": "2025-09-24T09:54:57.57",
  "InvoiceTypeCode": "PIE",
  "InvoiceDate": "24-09-2025",
  "InvoiceAmount": 125,
  "TaxAmount": 25,
  "ToBePaidAmount": 125,
  "Ean": null,
  "InvoiceNote": null,
  "InvoiceWasPaidManually": null,
  "InvoiceNumber": "2525",
  "PaymentDueDate": "2025-09-24T00:00:00",
  "Currency": "DKK",
  "Recepient": {
    "CustomerNumber": "1",
    "CompanyNo": null,
    "Gln": null,
    "Name": "John Doe",
    "Email": "[email protected]",
    "Street": null,
    "PostCode": null,
    "PoBox": null,
    "City": null,
    "Country": null,
    "ContactId": null,
    "ContactName": null,
    "ContactPhone": null,
    "ContactEmail": null
  },
  "Buyer": null,
  "Destination": null,
  "SchedulePayment": 0,
  "PaymentReference": null,
  "PaymentStatus": 100,
  "PaymentType": null,
  "InvoiceStatus": "Ok",
  "PaymentRejectedBy": null,
  "PdfInvoice": null,
  "PdfAttachments": null,
  "InvoiceLines": [
    {
      "LineNumber": 1,
      "ProductNumber": null,
      "Description": "Monthly subscription",
      "BasePrice": 100,
      "Quantity": 1,
      "UnitCode": null,
      "DiscountRate": 0,
      "DiscountedPrice": 0,
      "TaxRate": 0.25,
      "TaxAmount": 25,
      "Amount": 125
    }
  ],
  "TextLines": null,
  "Template": null,
  "OrderToken": null
}

Create Invoice

Create a new invoice for a customer.

POST https://api.farpay.io/v2/invoices

Request Body:

{
  "InvoiceDate": "2025-09-24",
  "InvoiceAmount": 125,
  "TaxAmount": 25,
  "ToBePaidAmount": 125,
  "Recepient": {
    "CustomerNumber": "1"
  },
  "InvoiceLines": [
    {
      "Description": "Monthly subscription",
      "BasePrice": 100,
      "Quantity": 1,
      "TaxRate": 0.25,
      "TaxAmount": 25,
      "Amount": 125
    }
  ]
}

Update Invoice

Update an existing invoice.

PUT https://api.farpay.io/v2/invoices/{invoiceId}

Request Body:

{
  "PaymentDueDate": "2025-09-15",
  "InvoiceLines": [
    {
      "Description": "Updated subscription",
      "Quantity": 1,
      "BasePrice": 150.00,
      "Amount": 150.00
    }
  ]
}

Delete Invoice

Delete an invoice (only possible in certain states).

DELETE https://api.farpay.io/v2/invoices/{invoiceId}

Invoice Properties

Core Properties

PropertyTypeDescriptionConstraints
IdintegerFarPay unique invoice identifierAuto-generated
CreateddatetimeInvoice creation timestampISO 8601 format
InvoiceNumberstringYour invoice numberRequired, unique
PaymentDueDatedateWhen payment is dueYYYY-MM-DD format
InvoiceAmountdecimalTotal invoice amount2 decimal places
ToBePaidAmountdecimalRemaining amount to be paid2 decimal places
PaymentReferenceStatusstringPayment reference status"Ok", "Error", etc.
PaymentTypestringPayment method typeSee Payment Types
SendStatusstringCommunication statusSee Send Status
ErrorDescriptionstringError details if anyOptional

Customer Information

PropertyTypeDescription
CustomerNumberstringCustomer's unique identifier
NamestringCustomer's full name
EmailstringCustomer's email address

Invoice Lines

PropertyTypeDescription
DescriptionstringLine item description
QuantitydecimalQuantity of items
UnitPricedecimalPrice per unit
TotalPricedecimalTotal line price

Payment Types

TypeDescription
MobilePayInvoiceMobilePay invoice payment
MobilePaySubscriptionsMobilePay subscription
BetalingsserviceDirect debit for private customers
LeverandørserviceDirect debit for businesses
FIManual payment (Faktura)
DankortDanish debit card
VisaVisa credit/debit card
MasterCardMasterCard credit/debit card

Send Status

The SendStatus indicates how the invoice will be processed regarding customer communication:

StatusDescription
QueueInvoice queued for sending
SentInvoice sent to customer
FailedFailed to send invoice
PendingAwaiting processing

Invoice Filtering

Date Range Filtering

Filter invoices by due date range:

GET https://api.farpay.io/v2/invoices?fromDueDate=2023-01-01&toDueDate=2023-01-31

Payment Status Filtering

Filter invoices by payment status:

GET https://api.farpay.io/v2/invoices?paymentStatus=200

Available status values: 100, 200, 300, 400, 500, 600, 700

Invoice Lifecycle

  1. Create Invoice - POST invoice details to create new invoice
  2. Send to Customer - Invoice is automatically sent based on SendStatus
  3. Customer Receives - Customer receives invoice via email/SMS
  4. Payment Processing - Customer pays through chosen payment method
  5. Status Updates - Invoice status updates as payment progresses
  6. Completion - Invoice marked as Paid or other final state

Best Practices

  1. Invoice Numbers: Use meaningful, unique identifiers for tracking
  2. Due Dates: Set realistic payment due dates
  3. Payment Types: Choose appropriate payment methods for your customers
  4. Invoice Lines: Provide clear, detailed line item descriptions
  5. Error Handling: Monitor ErrorDescription for failed invoices
  6. Status Monitoring: Regularly check invoice status for payment tracking

Error Handling

Common invoice-related errors:

ErrorDescriptionSolution
Invoice number already existsDuplicate invoice numberUse unique invoice numbers
Customer not foundInvalid customer numberVerify customer exists
Invalid payment typeUnsupported payment methodCheck available payment types
Invalid due dateDue date in the pastSet future due dates
Invoice cannot be updatedInvoice in locked stateCheck current invoice status

Integration Examples

Create Invoice with Multiple Lines

{
  "CustomerNumber": "12345",
  "InvoiceNumber": "INV-002",
  "PaymentDueDate": "2025-09-15",
  "PaymentType": "MobilePayInvoice",
  "InvoiceLines": [
    {
      "Description": "Basic subscription",
      "Quantity": 1,
      "BasePrice": 99.00,
      "Amount": 99.00
    },
    {
      "Description": "Premium add-on",
      "Quantity": 1,
      "BasePrice": 26.00,
      "Amount": 26.00
    }
  ]
}

Monitor Invoice Status

// Check invoice status
const invoice = await fetch(`/invoices/123`);
const status = invoice.PaymentReferenceStatus;

if (status === 'Ok') {
  console.log('Invoice is active');
} else if (status === 'Error') {
  console.log('Invoice has errors:', invoice.ErrorDescription);
}

Related Resources