Skip to content

Record payment dispute

POST
/v1/actions/hospitality.action.record_payment_dispute/apply
curl --request POST \
--url https://api.aerandil.com/v1/actions/hospitality.action.record_payment_dispute/apply \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "branch": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "params": { "amount": { "amount": "example", "currency": "example" }, "card_brand": "example", "charge_still_refundable": true, "closed_at": "2026-04-15T12:00:00Z", "dispute_fee": { "amount": "example", "currency": "example" }, "evidence_due_by": "2026-04-15T12:00:00Z", "evidence_past_due": true, "evidence_submitted_at": "2026-04-15T12:00:00Z", "funds_reinstated_at": "2026-04-15T12:00:00Z", "funds_withdrawn_at": "2026-04-15T12:00:00Z", "has_evidence": true, "network_reason_code": "example", "observed_at": "2026-04-15T12:00:00Z", "opened_at": "2026-04-15T12:00:00Z", "psp_dispute_reference": "example", "reason": "bank_cannot_process", "status": "inquiry_needs_response", "submission_count": 1, "visa_ce3_required_actions": [ "missing_customer_identifiers" ], "visa_ce3_status": "requires_action" }, "return_modified": false, "target": { "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "object_type": "hospitality.payment" } }'

Mirror a chargeback’s current state from the processor onto the payment it contests. Upserts on psp_dispute_reference: the first call mints the dispute and links it, later calls advance it, so every processor event about one case routes here and replay is a no-op. The kernel does not own this state machine. The card network decides a dispute and the processor reports it, so there is deliberately no guard on which transition is legal — lost to won really happens (Stripe’s “late win”, where an issuer moves money outside the normal lifecycle months later), and refusing it would leave the kernel insisting on a balance the bank disagrees with. What is guarded is staleness. Webhook delivery is not ordered, so observed_at is checked against the case’s last_observed_at and an older view is dropped rather than allowed to regress a decided case. Money is already gone by the time the first call lands: the network debits the disputed amount plus a non-refundable fee when the case opens. funds_reinstated_at is the only field that says it came back. A lost case reaches the ledger. On the move into lost the payment is reversed on its bill: a settled refund leg (refund_reason = chargeback_lost, capped at what the payment still has unrefunded) lands beside the original, on its folio (or the open rebate folio of a sealed one, or the booking), and the folio’s balance moves by it — the money the guest took back is owed again. Once per case. The network’s fee (dispute_fee, net of what a win returned) is recorded on the case, never on the guest’s bill: it is the merchant’s cost, and on a hotel’s own account the card rail passes it to the hotel at cost. A late win (lost to won) fails the leg and puts the balance back. An inquiry escalated to a chargeback (an inquiry state to needs_response) takes evidence again: the case records escalated_at, moves the inquiry’s evidence_submitted_at to inquiry_evidence_submitted_at and keeps the processor’s count then as inquiry_submission_count (the chargeback’s own submission is counted above it), and a packet submitted for the inquiry is kept as superseded_by_escalation. The CE 3.0 facts (card_brand, network_reason_code, visa_ce3_status, visa_ce3_required_actions) are mirrored when the view carries them.

Effects: create hospitality.payment_dispute; modify hospitality.payment_dispute; link hospitality.link.dispute_for_payment; create hospitality.payment; modify hospitality.payment; link hospitality.link.folio_has_payment; link hospitality.link.payment_refunds_payment; link hospitality.link.payment_for_reservation; modify hospitality.folio; modify hospitality.reservation; modify hospitality.dispute_evidence_packet.

Media typeapplication/json
object
branch

Apply against an open branch’s overlay view instead of the canonical (main) plane. The action’s writes land in the branch’s copy-on-first-write overlay, its events in the branch’s own stream, and the invocation is journaled for merge-by-replay. Branch writes are action-only, so this is the write-side entry point to a branch (POST /v1/branches forks one).

string format: uuid
params
required
object
amount
required
Disputed amount
object
amount
required
string format: decimal
currency
required
string format: iso-4217
card_brand
The disputed card's brand as the processor reports it
string
charge_still_refundable
Whether the disputed payment can still be refunded
boolean
closed_at
Closed at
string format: date-time
dispute_fee
What the processor charged for the case, net of any fee a win returned
object
amount
required
string format: decimal
currency
required
string format: iso-4217
evidence_due_by
Evidence deadline
string format: date-time
evidence_past_due
Whether the last submission reached the processor after the deadline
boolean
evidence_submitted_at
Evidence submitted at
string format: date-time
funds_reinstated_at
Funds reinstated at
string format: date-time
funds_withdrawn_at
Funds withdrawn at
string format: date-time
has_evidence
Whether the processor holds evidence for the case (staged or submitted)
boolean
network_reason_code
The card network's reason code for the case
string
observed_at
required
When the processor reported this state (the event's own timestamp, never the time of the call)
string format: date-time
opened_at
required
Opened at
string format: date-time
psp_dispute_reference
required
The processor's own id for the case — the upsert key
string
reason
required
Reason
string
Allowed values: bank_cannot_process check_returned credit_not_processed customer_initiated debit_not_authorized duplicate fraudulent general incorrect_account_details insufficient_funds noncompliant product_not_received product_unacceptable subscription_canceled unrecognized
status
required
Status
string
Allowed values: inquiry_needs_response inquiry_under_review inquiry_closed needs_response under_review won lost prevented
submission_count
Evidence submission count
integer
visa_ce3_required_actions
What the processor says the case still lacks for Visa CE 3.0
Array<string>
Allowed values: missing_customer_identifiers missing_disputed_transaction_description missing_merchandise_or_services missing_prior_undisputed_transaction_description missing_prior_undisputed_transactions
visa_ce3_status
The processor's Visa Compelling Evidence 3.0 status for the case
string
Allowed values: requires_action qualified not_qualified
return_modified

When true, the response carries modified_objects and modified_links projections — the engine reads the event log inside the same transaction so the projection observes the handler’s own writes.

boolean
target
required
object
id
required
string format: uuid
object_type
required
Allowed value: hospitality.payment

Action applied. modified_objects and modified_links populated when return_modified: true was supplied.

Media typeapplication/json
ApplyActionResponse

Envelope returned by the Aerandil action engine. correlation_id ties every event emitted by this invocation; modified_objects and modified_links project the events the handler emitted (per the action’s declared effects); warnings carries any non-blocking soft-validator observations.

object
correlation_id
required

Per-invocation correlation id; matches events.correlation_id for every event this action appended.

string format: uuid
modified_links
required

Links established or removed by this invocation. Empty when the caller did not request return_modified.

Array<object>
object
from_id
required
string format: uuid
from_type
required
string
kind
required
Allowed values: linked
link_type
required
Allowed values: hospitality.link.dispute_for_payment hospitality.link.folio_has_payment hospitality.link.payment_refunds_payment hospitality.link.payment_for_reservation
to_id
required
string format: uuid
to_type
required
string
modified_objects
required

Objects created, modified, or soft-deleted by this invocation. Empty when the caller did not request return_modified.

Array<object>
object
id
required
string format: uuid
kind
required
Allowed values: created modified
object_type
required
Allowed values: hospitality.payment_dispute hospitality.payment hospitality.folio hospitality.reservation hospitality.dispute_evidence_packet
warnings

Non-blocking soft-validator observations emitted during this invocation (e.g. comp-authority over-limit, recipe pour-cost over sell-price). Absent when no warnings were emitted.

Array<object>
object
message
required

Human-readable summary, suitable for logging or operator-UI surfacing.

string
object_type
required

Object type the warning was raised against.

string
property

Property the warning anchors to, when a single field is the locus. Absent for multi-field rules.

string
rule
required

Stable kebab-case rule identifier (e.g. comp-authority-over-limit).

string
Example
{
"modified_links": [
{
"kind": "linked",
"link_type": "hospitality.link.dispute_for_payment"
}
],
"modified_objects": [
{
"kind": "created",
"object_type": "hospitality.payment_dispute"
}
]
}

Conflict — concurrent modification or unique constraint violation.

Validation error — parameter validation or business-rule violation.