Skip to main content

Recording Credits

Basics

Marking an invoice as paid or adding installment payments is demonstrated in the following example file: ./examples/document/invoice/pay_invoice.php

To record a credit associated with an invoice, follow these steps:

// 1. Initialize a paper invoice
$invoice = new Invoice(Invoice::INVOICE_TYPE_E_INVOICE);

// 2. Set header data
$header = new InvoiceHeader();
$header->setInvoiceNumber('TEST-2021-001');

// 3. Add header data to the invoice
$invoice->setHeader($header);

// 4. Create a new credit note
$creditNote = new InvoiceCreditNote('2021-03-20', 10000.0, Document::PAYMENT_METHOD_BANKCARD, 'TEST');

// 5. Add the credit note to the invoice
$invoice->addCreditNote($creditNote);

// 6. Send the invoice credit note
$result = $agent->payInvoice($invoice);


## Expected and Optional Inputs

### Invoice Data

| Description | Field | Type | Required | Default |
|------------------|----------------|--------|----------|-----------|
| Invoice number | `invoiceNumber`| string | yes | |
| Credit method | `additive` | boolean| yes | true |
| Tax number | `taxNumber` | string | no | |


### Credit Note Data (Payment)

| Description | Field | Type | Required | Default |
|---------------------------|----------------|--------|----------|-----------|
| Date | `date` | string | yes | today |
| Justification (payment method) | `paymentMethod`| string | yes | transfer |
| Amount | `amount` | double | yes | 0.0 |
| Description | `description` | string | | |