PaymentBuilder
The `PaymentBuilder` is your primary tool for creating the JSON payload needed to create AR Payment records with the `PaymentsService`. It provides a fluent, chainable interface for setting payment fields and building complex nested lists, like documents to apply.
Importing the Builder
To get started, import the `PaymentBuilder` from the `easy_acumatica.models` module.
from easy_acumatica.models.payment_builder import PaymentBuilder
Builder Methods
Use the shortcut methods to set common header-level fields on the payment record. For any field not listed, use the generic `.set()` method.
payment_payload = (
PaymentBuilder()
.type("Payment")
.customer_id("CUST01")
.payment_amount(150.75)
.payment_method("CHECK")
.payment_ref("CHK-1055")
.cash_account("10200")
.hold(False)
)
The builder includes special methods for building the nested lists required for applying payments or including external transaction data.
.add_document_to_apply(...)
Adds a document like an invoice or credit memo to the `DocumentsToApply` list.
payment_payload.add_document_to_apply(
doc_type="INV",
reference_nbr="INV00451",
doc_line_nbr=1
)
.add_order_to_apply(...)
Adds a sales order to the `OrdersToApply` list.
payment_payload.add_order_to_apply(
order_type="SO",
order_nbr="SO00789"
)
.add_credit_card_transaction(...)
Adds externally processed credit card transaction data to the `CreditCardTransactionInfo` list.
payment_payload.add_credit_card_transaction(
tran_nbr="ext_tran_id_12345",
tran_type="Authorize and Capture",
auth_nbr="auth_code_abc789"
)