Skip to content

Money movement and financial logic

Payment flow testing

Payment flow testing verifies that card and account payments move from authorisation through capture, refund, reversal, and payout exactly once, in the correct amount, including timeouts, retries, webhooks, and 3-D Secure challenges. FintechAssuranceLabs delivers a payment flow map, a payment operation test suite, an idempotency test report, settlement and payout checks, and a defect log with financial impact.

What payment flow testing covers

We model each payment method as a state machine and test every transition and failure path between authorisation and payout. The sources below were checked on 2026-09-16.

Authorisation, capture, void, and reversal

  • Authorisation outcomes. Approval, hard decline, soft decline, partial approval, and issuer timeout, each mapped to the order state the payer sees.
  • Capture. Full capture, one partial capture, and several partial captures up to the authorised amount. A capture above the authorised amount is rejected. A capture after the authorisation expires follows your re-authorisation rule.
  • Void and reversal. A void before capture and a reversal of the uncaptured remainder after a partial capture. PSD2 Article 75(2) requires the payer's provider to release blocked funds without undue delay after it receives the exact amount, so a missing reversal message can keep the remainder of a hold on the payer's account.
  • Card-present. EMV chip and contactless authorisations, and a reversal when the terminal loses the authorisation response.

Refunds and partial refunds

The sum of partial refunds never exceeds the captured amount. A refund on a voided or uncaptured payment is rejected. A refund goes to the original payment method in the original currency, and a refund that the receiving account rejects returns to a queue with an owner. For debits from a US consumer account, Regulation E section 1005.11(a)(1)(ii) treats an incorrect electronic fund transfer as an error, and section 1005.11(c)(1) gives the financial institution 10 business days after a notice of error to determine whether the error occurred, or up to 45 days when it meets the provisional credit and notice conditions of section 1005.11(c)(2). A duplicated debit that the consumer reports starts that investigation clock; see the Regulation E testing requirements.

Retries, idempotency, and duplicate requests

RFC 9110 section 9.2.2 lists PUT, DELETE, and safe methods as idempotent. POST is not among them, so a client that retries a payment POST after a timeout creates a second charge unless the API deduplicates the request. The tests cover:

  • the same idempotency key with the same body, which returns the first response and creates one charge;
  • the same key with a different amount, which is rejected;
  • concurrent requests with one key, which produce one payment record;
  • a retry after the key expires, and a retry across a service restart;
  • a mobile client that resends after a network loss.

The payment idempotency testing guide shows the requests.

Webhooks and asynchronous state

Tests send duplicate events, out-of-order events (a refund event before its capture event), events delayed past an order cancellation, events with invalid signatures, and replays of old events. The state machine refuses illegal transitions, such as a refunded payment that returns to captured. Delivery infrastructure, retry schedules, and signing are covered in depth by API and webhook testing.

3-D Secure and strong customer authentication

EMV 3-D Secure tests cover the frictionless result (transStatus Y in the ARes), the challenge (transStatus C, then CReq and CRes, then the result in the RReq), attempts (A), rejection (R), and an unavailable service (U), plus the authorisation that follows each result. Delegated Regulation (EU) 2018/389 Article 5(1)(d) requires that any change to the amount or the payee invalidates the authentication code, so tests change the amount between authentication and authorisation. For a card payment with blocked funds, Article 5(3) makes the code specific to the amount the payer consented to block. PSD2 Article 74(2) states that when the payer's provider does not require strong customer authentication, the payer bears no financial loss unless the payer acted fraudulently, and a payee or payee's provider that fails to accept strong customer authentication refunds the financial damage caused to the payer's provider. See the PSD2 SCA and EMV 3DS requirements.

Settlement and payout checks

Captured and refunded amounts per business day match the processor settlement file lines and the payout amount, with tests for missing, duplicate, and late lines. Ledger-wide matching and break investigation belong to ledger reconciliation testing.

Deliverables

  • Payment flow map with every state, transition, and failure path

    A state diagram and transition table per payment method that lists each event, webhook, and failure path, for engineering leads who scope tests and auditors who review flows.

  • Test suite for authorisation, capture, void, refund, partial refund, and reversal

    Automated API and end-to-end tests for each payment operation, with amount limits, expired authorisations, and declines, that run in the client's CI pipeline.

  • Idempotency and duplicate-request test report

    A report per payment endpoint that records each retried, concurrent, and replayed request and the count of charges, refunds, and ledger entries it created.

  • Settlement file and payout reconciliation checks

    Checks that match captured and refunded payments to processor settlement file lines and to payouts, and flag missing, duplicate, and mismatched amounts.

  • Defect log with financial impact per defect

    A defect register that states the affected flow, the money at risk per transaction, the rule involved, and the retest result for each defect, for the engineering lead and the release owner.

How payment flow tests fit your release process

  • On every merge. State transition and idempotency tests run in your CI pipeline against a processor stub built from recorded sandbox responses. A pull request that adds an illegal transition fails the build.
  • Nightly and before release. The same suite runs against the processor sandbox, with 3-D Secure challenge flows in the processor's test environment and webhook delivery through your staging endpoint.
  • After release. A smoke check authorises, captures, and refunds one low-value payment on a production account your team owns and confirms each webhook.

Test data comes from processor test card numbers and synthetic accounts, under our rules for cardholder data and test environments. PCI DSS v4.0.1 requirement 6.5.5 keeps live PANs out of pre-production environments unless those environments sit inside the cardholder data environment, and requirement 6.5.6 removes test data and test accounts before a system goes into production (PCI SSC document library).

The flow map changes when you add a payment method, a processor, or a state. Canadian payment service providers can use the map for two rules of the Retail Payment Activities Regulations: section 5(1)(i)(vii) requires the incident response plan to address how the provider promptly identifies the status of all transactions during a service disruption, and section 9(1)(e) requires testing before any material change is adopted; see the RPAA requirements.

Handover per release: test suites committed to your repository in your test framework, run logs, the idempotency report, and the defect log. Your team owns processor credentials and sandbox accounts, fixes, and the go or no-go decision.

Sample deliverable

Sample, synthetic data

payment flow mapPayment flow map: card, ACH, and instant pay-ins and payouts
Payment flow map: card, ACH, and instant pay-ins and payouts
Step IDFrom stateEvent (webhook or file)To stateLedger effectTest cases
PFM-CARD-01Card pay-in createdWebhook payment.authorised for 150.00 XTSCard pay-in authorisedNo journal entry; the 150.00 XTS authorisation hold is stored as a memo recordTC-PF-001, TC-PF-002 (duplicate webhook delivery)
PFM-CARD-02Card pay-in authorisedWebhook payment.captured for 150.00 XTSCard pay-in capturedDr Processor receivable 150.00 XTS / Cr Merchant payable 150.00 XTSTC-PF-010, TC-PF-011 (capture retried with the same idempotency key)
PFM-CARD-03Card pay-in capturedProcessor settlement file line for the capture, with a 4.35 XTS fee lineCard pay-in settledDr Settlement bank cash 145.65 XTS and Dr Processing fee expense 4.35 XTS / Cr Processor receivable 150.00 XTSTC-PF-020, TC-PF-021 (settlement line with no matching capture)
PFM-ACH-01ACH debit pay-in pendingNacha return file entry with return code R01 (Insufficient Funds)ACH debit pay-in returnedDr Customer available balance 200.00 XTS / Cr ACH clearing 200.00 XTS, reversing the provisional creditTC-RL-030, TC-RL-031 (return received after the customer spent the provisional funds)
PFM-ACH-02ACH debit pay-in settledNacha return file entry with return code R10 (unauthorised debit), inside the 60-day extended return windowACH debit pay-in returned as unauthorisedDr Customer available balance 200.00 XTS / Cr ACH clearing 200.00 XTS, with any shortfall moved to a negative balance receivableTC-RL-032, TC-RL-033 (return that drives the customer balance below zero)
PFM-ACH-03ACH credit payout sentNacha return file entry with return code R03 (No Account/Unable to Locate Account)ACH credit payout returnedDr ACH clearing 500.00 XTS / Cr Beneficiary payable 500.00 XTS, restoring the amount owed to the beneficiaryTC-RL-040, TC-RL-041 (payout retry blocked until bank details change)
PFM-INST-01Instant payout submittedISO 20022 pacs.002 with transaction status ACSCInstant payout completedDr Instant payout clearing 75.00 XTS / Cr Settlement bank cash 75.00 XTSTC-RL-050, TC-RL-051 (pacs.002 received after the client timeout)
PFM-INST-02Instant payout submittedISO 20022 pacs.002 with transaction status RJCT and reason AC04 (Closed Account Number), sent to the client as webhook payout.failedInstant payout failedDr Instant payout clearing 75.00 XTS / Cr Customer available balance 75.00 XTS, reversing the payout debitTC-RL-052, TC-RL-053 (payout.failed webhook delivered before payout.submitted)

Amounts use XTS, the ISO 4217 code reserved for testing. States, webhook names, and ledger accounts are generic, and no real account or card data appears.

Questions

What is payment testing?

Payment testing checks the full life of a payment, from authorisation through capture, refund, and payout, against the amounts and states the business expects. Payment testing includes declined and timed-out requests, retried and duplicate requests, delayed or repeated webhooks, 3-D Secure challenges, and a comparison of captured payments with processor settlement files.

How to test payment gateway?

Payment gateway integration testing starts with a map of every payment state and transition. Each transition then runs against the gateway sandbox with the gateway's test card numbers. The test set adds declines, timeouts, retries with the same idempotency key, duplicate and out-of-order webhooks, and 3-D Secure challenges, and ends by matching captures and refunds to the sandbox settlement report.

Scope your payment flow testing

Send your payment methods, processor integrations, and refund rules, and we return a flow map outline and a test scope for your next release.

Scope your testing