The Payment entity represents payment information for an invoice. It includes the payment method, optional due date, amount, bank details, and support for installment payments.
Constructor
new Payment(
PaymentMethod $method,
?DateTimeImmutable $dueDate = null,
?float $amount = null,
?string $iban = null,
?string $bic = null,
?int $installmentIndex = null,
?int $totalInstallments = null
)
Parameters
dueDate
DateTimeImmutable|null
default:"null"
Payment due date. Required for some payment methods
Payment amount. For split payments, this is the amount of this specific installment
iban
string|null
default:"null"
International Bank Account Number for bank transfers or direct debits
bic
string|null
default:"null"
Bank Identifier Code (SWIFT code) for international transfers
Index of this installment (1-based) when using split payments
Total number of installments for split payments. When > 1, this indicates a split payment plan
Properties
All constructor parameters are exposed as public readonly properties:
International Bank Account Number
Installment index (1-based)
Total number of installments
Methods
isSplitPayment()
Determines if this payment is part of a split payment plan.
public function isSplitPayment(): bool
Returns: true if totalInstallments is greater than 1, false otherwise
PaymentMethod Enum
The PaymentMethod enum defines standard payment methods from the FacturaE specification:
Cash - Cash payment (01)
DirectDebit - Direct debit (02)
Transfer - Bank transfer (04)
Card - Card payment (19)
- And many more
Example Usage
Simple Transfer Payment
use PhpFacturae\Entities\Payment;
use PhpFacturae\Enums\PaymentMethod;
$payment = new Payment(
method: PaymentMethod::Transfer,
dueDate: new \DateTimeImmutable('+30 days'),
iban: 'ES9121000418450200051332'
);
Direct Debit with BIC
$payment = new Payment(
method: PaymentMethod::DirectDebit,
dueDate: new \DateTimeImmutable('2024-12-31'),
amount: 1500.00,
iban: 'ES9121000418450200051332',
bic: 'CAIXESBBXXX'
);
Cash Payment
$payment = new Payment(
method: PaymentMethod::Cash
);
Split Payment (Installments)
// First installment
$payment1 = new Payment(
method: PaymentMethod::Transfer,
dueDate: new \DateTimeImmutable('+30 days'),
amount: 500.00,
iban: 'ES9121000418450200051332',
installmentIndex: 1,
totalInstallments: 3
);
// Second installment
$payment2 = new Payment(
method: PaymentMethod::Transfer,
dueDate: new \DateTimeImmutable('+60 days'),
amount: 500.00,
iban: 'ES9121000418450200051332',
installmentIndex: 2,
totalInstallments: 3
);
// Third installment
$payment3 = new Payment(
method: PaymentMethod::Transfer,
dueDate: new \DateTimeImmutable('+90 days'),
amount: 500.00,
iban: 'ES9121000418450200051332',
installmentIndex: 3,
totalInstallments: 3
);
// Check if it's a split payment
var_dump($payment1->isSplitPayment()); // true
Adding Payments to Invoice
use PhpFacturae\Invoice;
$invoice = new Invoice(
// ... invoice parameters
);
$invoice->addPayment(
new Payment(
method: PaymentMethod::Card,
dueDate: new \DateTimeImmutable('+15 days'),
amount: 1210.00
)
);