Skip to content
EncryptTechBD
Home Industries Our Work Blog Pricing About Contact Discuss Your Project
বাংলা (BN)
Payments & Reconciliation 6 min read

Payment security logging: a step-by-step guide

How to build payment logs that answer who did what, when and to which transaction, without storing card data you should never keep.

E
EncryptTechBD · 0 comments
Calculator and printed spreadsheets on a desk
Photo: Negative Space / StockSnap

When a payment goes wrong, the first question is always the same: what actually happened? Without logs, the answer is a reconstruction from memory, screenshots and a support ticket. With good logs, it is a search result.

Payment logging is not the same as application logging. A debug log records that a function ran. A payment audit trail records that a specific transaction was authorised, captured, refunded or reversed, by which system, at what time, with what result. The distinction decides whether you can answer a customer, an auditor or a bank within minutes or within days.

The questions the log must answer

  • Which transaction, order and customer does this event belong to?
  • Which system or person triggered it, and from where?
  • What was the amount, currency and status before and after?
  • Which gateway reference or mobile money transaction ID links the records?
  • Did it succeed, fail, retry or time out, and with which error code?
  • Was the record altered after it was written, and by whom?

If a proposed log line does not help answer one of those questions, it is probably noise that will make the important records harder to find.

What must never appear in a log

Never write full card numbers, security codes, PINs, track data, gateway secret keys, full authentication tokens or complete customer identity documents into application logs. Log a masked reference or a token instead. The same rule applies to screenshots, exception traces and support attachments, which are logs by another name. A log store that quietly became a cardholder data store expands your compliance scope and your breach exposure at the same time.

Prerequisites

  • A list of every payment channel: gateway, aggregator, mobile financial service, bank transfer and cash on delivery.
  • Write access to the application, the web server and the log destination.
  • Time synchronisation on every server and container.
  • A retention decision agreed with finance, operations and whoever handles disputes.
  • A separate storage account or project with its own access list.
  • A test environment where you can generate a fake transaction end to end.

The step-by-step build

  1. Inventory the payment events. Authorisation, capture, failure, refund, partial refund, chargeback, settlement, callback, reconciliation adjustment. Each one needs a defined event name. Output: an event catalogue with the system that emits each event.
  2. Create a correlation identifier. Generate one ID when checkout starts and carry it through the gateway call, the callback, the order record and the reconciliation file. Without it, matching records becomes manual work. Output: the identifier field added to every payment table and log line.
  3. Define a fixed schema. At minimum: timestamp in UTC, event name, correlation ID, order ID, gateway reference, amount, currency, status, error code, actor, source service and environment. Structured fields beat free text because they can be searched and aggregated. Output: a schema document and a shared logging library.
  4. Classify and redact. Mark fields as public, internal, sensitive or prohibited. Apply redaction in the logging library, not in each developer's code. Output: a redaction test with sample payloads.
  5. Choose the pipeline and storage. Send events from the application to a collector, then to an append-only store or a security information and event management tool. Do not leave the only copy on the application server. Output: a diagram showing source, transport, store and reviewer.
  6. Synchronise clocks. Use NTP on every host, log in UTC and display in Bangladesh time only at the interface. A log without a trustworthy timestamp is an opinion. Output: clock offset checked on every host.
  7. Make records tamper-evident. Use write-once storage, a hash chain or signed batches, and keep delete rights with a small group separate from the application. Output: storage policy and the list of people who can delete.
  8. Control access and review it. Read-only access for analysts, multi-factor authentication for administrators, no shared analyst accounts, and a quarterly review. Output: access list with review dates.
  9. Set retention and rotation deliberately. PCI DSS expects at least twelve months of audit history with the most recent three months readily available, so check your validation route before choosing a shorter period. Confirm the requirement with your acquirer or assessor. Output: retention policy with a restore test.
  10. Add alerts that reflect risk. Spikes in failed authorisations, refunds above a threshold, repeated callback signature failures, settlement mismatches and log ingestion gaps. Alert on conditions someone can act on. Output: alert rules with an owner and a runbook link.
  11. Test the trail end to end. Run a test transaction, then find every related record using only the correlation ID. Measure how long it takes. Output: a timed search result with the date and the person who performed it.
  12. Rehearse the review. Once a month, pick a real transaction and reconstruct it from logs as if a customer had disputed it. Fix whatever required a phone call. Output: a monthly review note.

Evidence checklist

  • Event catalogue and schema document.
  • Redaction test results for card data and tokens.
  • Architecture diagram of the logging pipeline.
  • Sample record showing UTC timestamp and correlation ID.
  • Storage policy confirming append-only or write-once behaviour.
  • Access list with multi-factor authentication enabled.
  • Timed reconstruction of one transaction.

Common mistakes

  • Logging the full gateway response, which often contains sensitive fields nobody reviewed.
  • Keeping logs only on the web server, where a disk failure or a rebuild removes them.
  • Using local time on some services and UTC on others, making sequence reconstruction guesswork.
  • Giving the application account delete permission over its own audit trail.
  • Retaining everything forever, which increases cost and breach impact without improving investigations.
  • Treating log collection as complete when nobody has tested a search.

Metrics

  • Percentage of payment events carrying a correlation ID.
  • Median time to reconstruct a disputed transaction.
  • Log ingestion gaps longer than five minutes per month.
  • Redaction test pass rate across releases.
  • Number of people with delete rights over the log store.
  • Alert-to-incident conversion rate, which shows whether alerts are meaningful.

Local conditions

Bangladeshi payment stacks usually combine a card gateway, one or more mobile financial services and a manual reconciliation file. Each source uses a different reference format, and callbacks can arrive late or twice. Log the raw gateway reference alongside your internal ID, store the settlement file checksum, and record the operator who applied a manual adjustment. When a customer sends a bKash transaction ID to a support inbox, that reference is often the only thread back to the order.

Where this fits in our work

We design payment flows and their audit trails through Commerce Systems, with scope and pricing explained on the pricing page. When a payment incident does occur, the steps in the SME incident response guide show how logs feed the investigation.

Sources

Services that deliver this

Want this implemented properly?

Pricing →

Every engagement starts with a written scope. If a requirement is outside it, we quote it separately before starting.

Responses (0)

No comments yet. Add the first one below.

Leave a response

Your email address will not be published. Required fields are marked *.

Keep reading

More field notes