# Payments and credit notes

> Record payments of your PPD invoices with payment complements, and discounts or returns with credit notes.

## Payment complements

A PPD invoice (on credit or in installments) is collected with a payment complement (CFDI type P) for each payment it receives. SAT requires it to be stamped no later than the fifth calendar day of the month after the payment.

You only say which invoices it pays and how much of each. Fiscalisto calculates the installment number, the previous balance and the remaining balance, and each invoice's taxes in proportion.

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/payments \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Idempotency-Key: pago-SPEI-2026102400123" \
  -H "Content-Type: application/json" \
  -d '{
    "payment_form": "03",
    "operation_number": "SPEI-2026102400123",
    "documents": [{ "invoice": "inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg", "amount": 2900 }],
    "send_email": true
  }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

// The key comes from FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const invoice = await fiscalisto.payments.create({
  payment_form: "03",
  operation_number: "SPEI-2026102400123",
  documents: [
    {
      invoice: "inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg",
      amount: 2900,
    },
  ],
  send_email: true,
}, { idempotencyKey: "pago-SPEI-2026102400123" });
```

```python tab="Python"
from fiscalisto import Fiscalisto

# The key comes from FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

invoice = fiscalisto.payments.create({
    "payment_form": "03",
    "operation_number": "SPEI-2026102400123",
    "documents": [
        {
            "invoice": "inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg",
            "amount": 2900,
        },
    ],
    "send_email": True,
}, idempotency_key="pago-SPEI-2026102400123")
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$invoice = $fiscalisto->payments->create([
    'payment_form' => '03',
    'operation_number' => 'SPEI-2026102400123',
    'documents' => [
        [
            'invoice' => 'inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg',
            'amount' => 2900,
        ],
    ],
    'send_email' => true,
], ['idempotency_key' => 'pago-SPEI-2026102400123']);
```

```go tab="Go"
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// The key comes from FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	invoice, err := client.Payments.Create(ctx, &fiscalisto.CreatePaymentParams{
		PaymentForm:     "03",
		OperationNumber: fiscalisto.String("SPEI-2026102400123"),
		Documents: []fiscalisto.CreatePaymentParamsDocument{
			{
				Invoice: "inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg",
				Amount:  2900,
			},
		},
		SendEmail: fiscalisto.Bool(true),
	}, fiscalisto.WithIdempotencyKey("pago-SPEI-2026102400123"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(invoice.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.CreatePaymentParams;
import com.fiscalisto.model.CreatePaymentParamsDocument;
import java.util.List;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var invoice = fiscalisto.payments().create(new CreatePaymentParams()
        .setPaymentForm("03")
        .setOperationNumber("SPEI-2026102400123")
        .setDocuments(List.of(
                new CreatePaymentParamsDocument()
                        .setInvoice("inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg")
                        .setAmount(2900)
        ))
        .setSendEmail(true), RequestOptions.idempotencyKey("pago-SPEI-2026102400123"));
System.out.println(invoice.getId());
```

```csharp tab="C#"
using Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var invoice = await fiscalisto.Payments.CreateAsync(new CreatePaymentParams
{
    PaymentForm = "03",
    OperationNumber = "SPEI-2026102400123",
    Documents = new()
    {
        new()
        {
            Invoice = "inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg",
            Amount = 2900,
        },
    },
    SendEmail = true,
}, new RequestOptions { IdempotencyKey = "pago-SPEI-2026102400123" });
```

- `documents` accepts up to 100 invoices of the same customer, by their id or their UUID. `amount` is what's paid of each, in the invoice's currency. Only invoices stamped with the API can be paid.
- Without `date`, the payment is today's. If you were paid another day, send `date` (`2026-10-20`).
- If the invoice is in dollars and you were paid in pesos, the payment goes in MXN and each document carries `amount` in dollars (what's credited to the invoice) and `received` in pesos (what you got for it). If you were paid in dollars, send `currency: "USD"` and the payment day's `exchange_rate`.
- If `amount` is greater than the invoice's balance, it isn't stamped: the error says the remaining balance.
- If the payment is a deposit you sent to [Bank reconciliation](https://fiscalisto.com/en/docs/api/conciliacion-bancaria), send `bank_transaction` (`btx_…`): the complement carries the deposit's date and leaves it reconciled.

The response is an `invoice` object of `type: "P"`, with `payment` (form, date, amount and each document with its installment and balances). Each paid invoice lowers its `amount_due` and `invoice.partially_paid` or `invoice.paid` arrives ([Accounts receivable](https://fiscalisto.com/en/docs/api/cuentas-por-cobrar)).

## Credit notes

A discount, a rebate or a return on an invoice already stamped goes in a credit note (CFDI type E) related to it. `amount` is before taxes: Fiscalisto applies the invoice's IVA and withholdings in the same proportion.

```bash tab="cURL"
curl https://api.fiscalisto.com/v1/credit_notes \
  -H "Authorization: Bearer $FISCALISTO_API_KEY" \
  -H "Idempotency-Key: descuento-A-1042" \
  -H "Content-Type: application/json" \
  -d '{
    "invoice": "inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg",
    "amount": 500,
    "description": "Descuento por pronto pago",
    "payment_form": "03"
  }'
```

```ts tab="TypeScript"
import { Fiscalisto } from "fiscalisto";

// The key comes from FISCALISTO_API_KEY.
const fiscalisto = new Fiscalisto();

const invoice = await fiscalisto.creditNotes.create({
  invoice: "inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg",
  amount: 500,
  description: "Descuento por pronto pago",
  payment_form: "03",
}, { idempotencyKey: "descuento-A-1042" });
```

```python tab="Python"
from fiscalisto import Fiscalisto

# The key comes from FISCALISTO_API_KEY.
fiscalisto = Fiscalisto()

invoice = fiscalisto.credit_notes.create({
    "invoice": "inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg",
    "amount": 500,
    "description": "Descuento por pronto pago",
    "payment_form": "03",
}, idempotency_key="descuento-A-1042")
```

```php tab="PHP"
<?php

use Fiscalisto\Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
$fiscalisto = new Fiscalisto();

$invoice = $fiscalisto->creditNotes->create([
    'invoice' => 'inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg',
    'amount' => 500,
    'description' => 'Descuento por pronto pago',
    'payment_form' => '03',
], ['idempotency_key' => 'descuento-A-1042']);
```

```go tab="Go"
package main

import (
	"context"
	"fmt"
	"log"

	fiscalisto "fiscalisto.com/go"
)

func main() {
	// The key comes from FISCALISTO_API_KEY.
	client, err := fiscalisto.NewClient("")
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	invoice, err := client.CreditNotes.Create(ctx, &fiscalisto.CreateCreditNoteParams{
		Invoice:     "inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg",
		Amount:      500,
		Description: fiscalisto.String("Descuento por pronto pago"),
		PaymentForm: "03",
	}, fiscalisto.WithIdempotencyKey("descuento-A-1042"))
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(invoice.ID)
}
```

```java tab="Java"
import com.fiscalisto.FiscalistoClient;
import com.fiscalisto.RequestOptions;
import com.fiscalisto.model.CreateCreditNoteParams;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var invoice = fiscalisto.creditNotes().create(new CreateCreditNoteParams()
        .setInvoice("inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg")
        .setAmount(500)
        .setDescription("Descuento por pronto pago")
        .setPaymentForm("03"), RequestOptions.idempotencyKey("descuento-A-1042"));
System.out.println(invoice.getId());
```

```csharp tab="C#"
using Fiscalisto;

// The key comes from FISCALISTO_API_KEY.
var fiscalisto = new FiscalistoClient();

var invoice = await fiscalisto.CreditNotes.CreateAsync(new CreateCreditNoteParams
{
    Invoice = "inv_OufpKqnrvx9p0Nfbydl9jG4UNGeTYcvdrg",
    Amount = 500,
    Description = "Descuento por pronto pago",
    PaymentForm = "03",
}, new RequestOptions { IdempotencyKey = "descuento-A-1042" });
```

`invoice` is the invoice's id (`inv_…`) or its UUID. With a UUID, if your account has several issuers, say which one with `issuer` (`iss_…`); with an `inv_…` it isn't needed.

By default the relationship is `01` (credit note); for a return of goods send `"relationship": "03"`. If the invoice is PPD and not yet paid, a credit note lowers its balance for the following payment complements.

A global invoice also takes credit notes, for example when a sale included in it is returned. The note goes to the general public like the global (RFC `XAXX010101000`, name `PUBLICO EN GENERAL`, regime `616` and the issuer's postal code), with the key `84111506` and the unit `ACT`, and without the global information (`InformacionGlobal`), as in the example of SAT's filling guide for the global CFDI.

## Advances

If the customer pays you before knowing what they'll buy, stamp the advance invoice with [`POST /v1/advances`](https://fiscalisto.com/en/docs/api/referencia/anticipos/create-advance) (`amount` is what they paid, with IVA). When what was sold is delivered, [`POST /v1/advances/{id}/apply`](https://fiscalisto.com/en/docs/api/referencia/anticipos/apply-advance) stamps the sale's invoice related to the advance, with either of SAT's two options: with `"method": "egreso"` also a credit note for what was advanced; with `"method": "remanente"` the invoice only for what's left to pay.
