---
updatedAt: 2026-07-16T01:50:22.000Z
agentTools:
  projectIndex: https://docs.payadvantage.com.au/llms.txt
---

# Create an invoice from an existing payment

Manage merchant invoices. Invoices allows for line items. Invoices status lifecycle is: (Draft → Sent → Paid / Cancelled). You can also connect an invoice to any payment.<br><hr><br>Creates an invoice from an existing payment. Uses the payment description as the line item, applies the merchant's default tax code, and links the payment. The invoice is marked Paid when the payment's effective amount covers the total; a failed (or partially effective) payment leaves the invoice Approved with the balance still due.

# OpenAPI definition

```json
{
  "openapi": "3.0.4",
  "info": {
    "title": "PayAdvantage Web API",
    "termsOfService": "https://www.payadvantage.com.au/terms-of-service",
    "contact": {
      "name": "Support",
      "url": "https://help.payadvantage.com.au/hc/en-us/categories/360000110195",
      "email": "support@payadvantage.com.au"
    },
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://api.test.payadvantage.com.au/v3/"
    }
  ],
  "paths": {
    "/create_invoice_from_payment": {
      "post": {
        "tags": [
          "Invoice"
        ],
        "summary": "Create an invoice from an existing payment",
        "description": "Manage merchant invoices. Invoices allows for line items. Invoices status lifecycle is: (Draft → Sent → Paid / Cancelled). You can also connect an invoice to any payment.<br><hr><br>Creates an invoice from an existing payment. Uses the payment description as the line item, applies the merchant's default tax code, and links the payment. The invoice is marked Paid when the payment's effective amount covers the total; a failed (or partially effective) payment leaves the invoice Approved with the balance still due.",
        "operationId": "invoices_create_from_payment",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateInvoiceFromPaymentRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "The created Invoice.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InvoiceResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "User is not authorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The request was valid, but the server is refusing action. The user might not have the necessary permissions for a resource, or may need an account of some sort",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "The requested resource could not be found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          },
          "422": {
            "description": "The request was well-formed but was unable to be followed due to semantic errors",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Request limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          },
          "504": {
            "description": "Gateway timeout",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ApiErrorResponse": {
        "type": "object",
        "properties": {
          "ErrorCode": {
            "type": "string",
            "nullable": true,
            "example": "abc"
          },
          "Messages": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "CodeOnly": {
        "type": "object",
        "properties": {
          "Code": {
            "pattern": "^[0-9A-Z]{6}$",
            "type": "string",
            "description": "The entities code.",
            "nullable": true,
            "example": "ABC123"
          }
        },
        "additionalProperties": false,
        "example": {
          "Code": "ABC123"
        }
      },
      "CreateInvoiceFromPaymentRequest": {
        "required": [
          "Payment"
        ],
        "type": "object",
        "properties": {
          "Payment": {
            "$ref": "#/components/schemas/CodeOnly"
          }
        },
        "additionalProperties": false,
        "example": {
          "Payment": {
            "Code": "PAY123"
          }
        }
      },
      "CustomerInvoiceStatus": {
        "enum": [
          "draft",
          "approved",
          "paid",
          "cancelled"
        ],
        "type": "string"
      },
      "CustomerSummary": {
        "type": "object",
        "properties": {
          "Code": {
            "pattern": "^[0-9A-Z]{6}$",
            "type": "string",
            "description": "The entities code.",
            "nullable": true,
            "example": "abc"
          },
          "Name": {
            "type": "string",
            "description": "Name of customer or business",
            "nullable": true,
            "example": "abc"
          },
          "CustomRef": {
            "type": "string",
            "description": "Custom reference number for a customer.",
            "nullable": true,
            "example": "abc"
          },
          "ExternalID": {
            "type": "string",
            "description": "The entities ID from the external system that created it.",
            "nullable": true,
            "example": "abc"
          }
        },
        "additionalProperties": false
      },
      "DDRVirtualStatusIDs": {
        "enum": [
          "Unknown",
          "Pending",
          "Active",
          "Rejected",
          "Cancelled",
          "Complete",
          "Draft",
          "AllPreActivation",
          "Paused",
          "AllIncomplete",
          "Error"
        ],
        "type": "string"
      },
      "InvoiceCreditResponse": {
        "required": [
          "Amount",
          "IsCancelled",
          "TaxAmount"
        ],
        "type": "object",
        "properties": {
          "Code": {
            "type": "string",
            "description": "Unique identifier code for this credit.",
            "nullable": true,
            "readOnly": true,
            "example": "abc"
          },
          "Amount": {
            "type": "number",
            "description": "Amount credited toward this invoice.",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "Reason": {
            "type": "string",
            "description": "Optional reason for the credit.",
            "nullable": true,
            "readOnly": true,
            "example": "abc"
          },
          "TaxAmount": {
            "type": "number",
            "description": "GST component of this credit (proportional to the invoice blended tax rate).",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "DateCreated": {
            "pattern": "\\d\\d\\d\\d\\-\\d\\d\\-\\d\\dT\\d\\d:\\d\\d(:\\d\\d(\\.\\d{1,7})?(Z|([+\\-]\\d\\d:\\d\\d))?)?",
            "type": "string",
            "description": "Date and time the credit was applied.",
            "format": "date",
            "nullable": true,
            "readOnly": true,
            "example": "2022-12-31"
          },
          "IsCancelled": {
            "type": "boolean",
            "description": "Whether this credit has been cancelled. Cancelled credits are retained for history and do not count toward the invoice balance.",
            "readOnly": true,
            "example": true
          },
          "DateCancelled": {
            "pattern": "\\d\\d\\d\\d\\-\\d\\d\\-\\d\\dT\\d\\d:\\d\\d(:\\d\\d(\\.\\d{1,7})?(Z|([+\\-]\\d\\d:\\d\\d))?)?",
            "type": "string",
            "description": "Date and time the credit was cancelled, if applicable.",
            "format": "date",
            "nullable": true,
            "readOnly": true,
            "example": "2022-12-31"
          },
          "CancelledBy": {
            "type": "string",
            "description": "Name of the user who cancelled the credit, if applicable.",
            "nullable": true,
            "readOnly": true,
            "example": "abc"
          }
        },
        "additionalProperties": false
      },
      "InvoiceLineItemResponse": {
        "required": [
          "Amount",
          "Discount",
          "Quantity",
          "SortOrder",
          "TaxAmount"
        ],
        "type": "object",
        "properties": {
          "Description": {
            "type": "string",
            "description": "Description of the goods or services.",
            "nullable": true,
            "readOnly": true,
            "example": "abc"
          },
          "Quantity": {
            "type": "number",
            "description": "Quantity of units.",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "UnitPrice": {
            "type": "number",
            "description": "Unit price per item. Null when amount was entered directly.",
            "format": "double",
            "nullable": true,
            "readOnly": true
          },
          "Amount": {
            "type": "number",
            "description": "Total line amount (quantity x unitPrice, or directly entered).",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "TaxAmount": {
            "type": "number",
            "description": "Tax amount for this line item.",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "Discount": {
            "type": "number",
            "description": "Discount amount subtracted from the line subtotal.",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "SortOrder": {
            "type": "integer",
            "description": "Display order of this line item.",
            "format": "int16",
            "readOnly": true,
            "example": 1
          },
          "TaxCode": {
            "type": "string",
            "description": "The tax code applied to this line item.",
            "nullable": true,
            "example": "abc"
          },
          "TaxRate": {
            "type": "number",
            "description": "Tax rate applied to this line item (e.g. 10 for 10%). Null if no tax code is set.",
            "format": "double",
            "nullable": true,
            "readOnly": true
          },
          "Product": {
            "type": "string",
            "description": "The product used for this line item, if selected from the products catalogue.",
            "nullable": true,
            "example": "abc"
          }
        },
        "additionalProperties": false
      },
      "InvoicePaymentPlanResponse": {
        "required": [
          "InstallmentsPaid",
          "InstallmentsTotal"
        ],
        "type": "object",
        "properties": {
          "DirectDebit": {
            "$ref": "#/components/schemas/CodeOnly"
          },
          "Status": {
            "$ref": "#/components/schemas/DDRVirtualStatusIDs"
          },
          "InstallmentsTotal": {
            "type": "integer",
            "description": "Total number of instalments in the plan.",
            "format": "int32",
            "readOnly": true,
            "example": 1
          },
          "InstallmentsPaid": {
            "type": "integer",
            "description": "Number of instalments that have settled so far.",
            "format": "int32",
            "readOnly": true,
            "example": 1
          }
        },
        "additionalProperties": false
      },
      "InvoicePaymentResponse": {
        "required": [
          "Amount",
          "AmountChargedback",
          "AmountRefunded",
          "EffectiveAmount",
          "IncludedFees",
          "IsFailed"
        ],
        "type": "object",
        "properties": {
          "Payment": {
            "$ref": "#/components/schemas/CodeOnly"
          },
          "Amount": {
            "type": "number",
            "description": "Base amount of this payment (does not include surcharged fees).",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "IncludedFees": {
            "type": "number",
            "description": "Processing fees surcharged to the customer for this payment (does not reduce invoice balance).",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "DateCreated": {
            "pattern": "\\d\\d\\d\\d\\-\\d\\d\\-\\d\\dT\\d\\d:\\d\\d(:\\d\\d(\\.\\d{1,7})?(Z|([+\\-]\\d\\d:\\d\\d))?)?",
            "type": "string",
            "description": "Date of the payment.",
            "format": "date",
            "nullable": true,
            "readOnly": true,
            "example": "2022-12-31"
          },
          "IsFailed": {
            "type": "boolean",
            "description": "Whether this payment has failed.",
            "readOnly": true,
            "example": true
          },
          "AmountRefunded": {
            "type": "number",
            "description": "Total amount refunded from this payment.",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "AmountChargedback": {
            "type": "number",
            "description": "Total amount charged back from this payment.",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "EffectiveAmount": {
            "type": "number",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          }
        },
        "additionalProperties": false
      },
      "InvoiceResponse": {
        "required": [
          "AmountPaid",
          "AmountPaidIncCredits",
          "AmountRemaining",
          "AmountTaxPaid",
          "BlendedTaxRate",
          "DateIssued",
          "HasLivePaymentPlan",
          "ShowNotesToCustomer",
          "TaxExclusive",
          "TotalAmount",
          "TotalTax"
        ],
        "type": "object",
        "properties": {
          "Code": {
            "type": "string",
            "description": "Unique identifier for the invoice.",
            "nullable": true,
            "readOnly": true,
            "example": "abc"
          },
          "Number": {
            "type": "string",
            "description": "Your merchant-supplied invoice number.",
            "nullable": true,
            "readOnly": true,
            "example": "abc"
          },
          "Status": {
            "$ref": "#/components/schemas/CustomerInvoiceStatus"
          },
          "TotalAmount": {
            "type": "number",
            "description": "Total amount of all line items (excluding tax).",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "TotalTax": {
            "type": "number",
            "description": "Total tax amount across all line items.",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "BlendedTaxRate": {
            "type": "number",
            "description": "Blended tax rate for this invoice (totalTax / totalAmount), rounded to 4 decimal places. The authoritative GST component of a credit is taxAmount on that credit.",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "DateIssued": {
            "pattern": "^\\d\\d\\d\\d\\-\\d\\d\\-\\d\\d$",
            "type": "string",
            "description": "Date the invoice was issued.",
            "format": "date",
            "readOnly": true,
            "example": "2022-12-31"
          },
          "DateDue": {
            "pattern": "^\\d\\d\\d\\d\\-\\d\\d\\-\\d\\d$",
            "type": "string",
            "description": "Due date for payment, if set.",
            "format": "date",
            "nullable": true,
            "readOnly": true,
            "example": "2022-12-31"
          },
          "DateApproved": {
            "pattern": "\\d\\d\\d\\d\\-\\d\\d\\-\\d\\dT\\d\\d:\\d\\d(:\\d\\d(\\.\\d{1,7})?(Z|([+\\-]\\d\\d:\\d\\d))?)?",
            "type": "string",
            "description": "Date and time the invoice was approved.",
            "format": "date",
            "nullable": true,
            "readOnly": true,
            "example": "2022-12-31"
          },
          "Notes": {
            "type": "string",
            "description": "Notes or message to the customer.",
            "nullable": true,
            "readOnly": true,
            "example": "abc"
          },
          "Reference": {
            "type": "string",
            "description": "Merchant internal reference.",
            "nullable": true,
            "readOnly": true,
            "example": "abc"
          },
          "ExternalId": {
            "type": "string",
            "description": "Identifier from your own system.",
            "nullable": true,
            "readOnly": true,
            "example": "abc"
          },
          "Customer": {
            "$ref": "#/components/schemas/CustomerSummary"
          },
          "LineItems": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceLineItemResponse"
            },
            "description": "Line items on this invoice.",
            "nullable": true
          },
          "Payments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoicePaymentResponse"
            },
            "description": "Payments linked to this invoice.",
            "nullable": true
          },
          "Credits": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InvoiceCreditResponse"
            },
            "description": "Credits applied to this invoice.",
            "nullable": true
          },
          "AmountPaid": {
            "type": "number",
            "description": "Total amount already paid toward this invoice.",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "AmountTaxPaid": {
            "type": "number",
            "description": "Total tax amount already paid toward this invoice.",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "AmountPaidIncCredits": {
            "type": "number",
            "description": "Total amount already paid toward this invoice (including credits).",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "AmountRemaining": {
            "type": "number",
            "description": "Remaining amount due on this invoice (total - amountPaid).",
            "format": "double",
            "readOnly": true,
            "example": 1.23
          },
          "ShowNotesToCustomer": {
            "type": "boolean",
            "description": "Whether notes on this invoice are visible to the customer on the hosted invoice page.",
            "readOnly": true,
            "example": true
          },
          "TaxExclusive": {
            "type": "boolean",
            "description": "Whether line item unit prices are tax exclusive (tax added on top) rather than tax inclusive.",
            "readOnly": true,
            "example": true
          },
          "HostedUrl": {
            "type": "string",
            "description": "Customer-facing URL for viewing and paying this invoice via Hosted Pages.",
            "nullable": true,
            "readOnly": true,
            "example": "abc"
          },
          "PaymentPlan": {
            "$ref": "#/components/schemas/InvoicePaymentPlanResponse"
          },
          "HasLivePaymentPlan": {
            "type": "boolean",
            "description": "Whether a live payment plan (Pending, Active, or Paused) is collecting this invoice. A live plan blocks the invoice from being paid by other means.",
            "readOnly": true,
            "example": true
          },
          "PaymentRequest": {
            "$ref": "#/components/schemas/CodeOnly"
          },
          "PaidInvoiceUrl": {
            "type": "string",
            "description": "Customer-facing Hosted Pages URL for viewing this invoice, returned only once the invoice is Paid so it can be shared as a record of the paid invoice. Null in every other status (collect payment via the payment request instead).",
            "nullable": true,
            "example": "abc"
          }
        },
        "additionalProperties": false,
        "example": {
          "Code": "INV001",
          "Number": "INV-001",
          "Status": "approved",
          "TotalAmount": 300,
          "TotalTax": 30,
          "BlendedTaxRate": 0,
          "DateIssued": "2026-10-03",
          "DateDue": "2026-11-02",
          "DateApproved": null,
          "Notes": "Thank you for your business.",
          "Reference": "PO-2026-001",
          "ExternalId": "your-external-id",
          "Customer": {
            "Code": "CUS001",
            "Name": "Acme Corp",
            "CustomRef": null,
            "ExternalID": null
          },
          "LineItems": [
            {
              "Description": "Consulting Services",
              "Quantity": 2,
              "UnitPrice": 150,
              "Amount": 300,
              "TaxAmount": 30,
              "Discount": 0,
              "SortOrder": 0,
              "TaxCode": null,
              "TaxRate": null,
              "Product": null
            }
          ],
          "Payments": [],
          "Credits": [],
          "AmountPaid": 0,
          "AmountTaxPaid": 0,
          "AmountPaidIncCredits": 0,
          "AmountRemaining": 330,
          "ShowNotesToCustomer": false,
          "TaxExclusive": false,
          "HostedUrl": null,
          "PaymentPlan": null,
          "HasLivePaymentPlan": false,
          "PaymentRequest": null,
          "PaidInvoiceUrl": null
        }
      }
    }
  }
}
```