Skip to content

feat(payments): record an out-of-band gateway payment with its reference and date - #326

Open
modernitconsultants wants to merge 1 commit into
TelivityAI:mainfrom
modernitconsultants:feat/out-of-band-gateway-payment
Open

feat(payments): record an out-of-band gateway payment with its reference and date#326
modernitconsultants wants to merge 1 commit into
TelivityAI:mainfrom
modernitconsultants:feat/out-of-band-gateway-payment

Conversation

@modernitconsultants

Copy link
Copy Markdown
Contributor

Reconciling money means matching three things by id: what was due, what the ledger holds, and what the provider actually took.

The payments table already has gateway_transaction_id — but CreatePaymentDto doesn't accept it, and only the authorize/capture path can populate it. So a payment taken outside the PMS (a payment link the guest paid, a terminal, a charge made in the provider's own dashboard) can only be recorded with no reference back to the provider at all, and nothing to reconcile against a settlement report.

The settle-path guard is refined, not relaxed

It was conflating two opposites:

  • A token is a chargeable instrument. Presenting one here is an attempt to take money through the settle path, and still goes via POST /payments/authorize. Unchanged.
  • A transaction id is evidence a charge already happened elsewhere. Recording it after the fact is the only way that payment becomes reconcilable.

So a card method carrying a token is still refused, and a card method naming a gateway must now carry either a transaction id or use authorize — naming a provider with neither is what the original guard was really aimed at, and stays refused.

processedAt is the same argument, for time

A historical import stamped with the import date makes the ledger disagree with the settlement report it exists to be reconciled against. Optional, refused if in the future, and resolved explicitly rather than left to the object spread — where it would have been carried through as a string and then silently overwritten by the hardcoded new Date().

Specs

Both directions, including the negative control: omitting processedAt must still stamp now, or the positive test could pass while the field was ignored entirely.

Context: this came out of a two-week integration against a live property with real Square payments taken outside the PMS — the same work behind #321.

…nce and date

Reconciling money means matching three things by id: what was due, what the
ledger holds, and what the provider actually took. The payments table already
has gateway_transaction_id, but CreatePaymentDto did not accept it and only the
authorize/capture path could populate it. So a payment taken OUTSIDE the PMS — a
payment link the guest paid, a terminal, a charge made in the provider's own
dashboard — could only be recorded with no reference back to the provider at
all, and nothing to reconcile against a settlement report.

The settle-path guard is refined rather than relaxed, because it was conflating
two opposites. A TOKEN is a chargeable instrument: presenting one here is an
attempt to take money through the settle path and still goes via authorize. A
TRANSACTION ID is evidence a charge already happened elsewhere. So a card method
carrying a token is still refused, and a card method naming a gateway must now
carry either a transaction id or use authorize — naming a provider with neither
is what the original guard was really aimed at, and stays refused.

processedAt is the same argument for time. A historical import stamped with the
import date makes the ledger disagree with the settlement report it exists to be
reconciled against. Optional, refused if in the future, and resolved explicitly
rather than left to the object spread — where it would have been carried through
as a string and then silently overwritten by the hardcoded new Date().

Specs cover both directions, including the negative control: omitting
processedAt must still stamp now, or the positive test could pass while the
field was ignored entirely.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant