Skip to main content

Quality assurance

Testing payment flows: what to check before you launch

By Ateeq Ahmad · Code Huddle · Product engineering guides

A payment test is not finished when the provider approves a transaction. The customer must be charged once, for the right amount, and receive exactly what they paid for, while your records stay consistent with the provider's. Test the complete lifecycle, including failures, retries, refunds and delayed notifications, not only the success screen.

1. Follow one payment through every system it touches

A typical payment crosses several boundaries: the checkout page, your application, the payment provider, the card network and bank, and back again. Many providers then send a separate notification, called a webhook, after the customer has already left the page. A defect can appear at any of these steps.

Write down one complete journey and the expected result in each system. For a subscription purchase, that might be: the customer chooses a plan, enters card details, completes any bank authentication, sees a confirmation, receives access, gets a receipt email, and appears correctly in the admin panel and reports. A green "Payment successful" message proves very little if the order was never created.

Customer screen — Confirmation shown once

Payment provider — One successful charge for the expected amount

Order or subscription — Created and active

Customer account — Correct access granted

Email — One receipt with correct details

Admin panel and reports — Transaction visible with the same amount

Most providers offer a test mode with card numbers that simulate approvals, declines and authentication challenges. Use it in a dedicated test environment, never with real customer cards.

2. Test failures as carefully as successful payments

Real checkouts include declined cards, expired cards, insufficient funds, incorrect security codes and provider errors. In regions that require strong customer authentication, such as the UK and the European Economic Area, customers may also be asked to confirm the payment with their bank. Some will fail or abandon that step.

For each failure, check what the customer sees and what the system records. The message should explain what to do next without exposing technical detail. No order should be created, no access should be granted, and the customer should be able to try again with another payment method where that is allowed.

  • Card declined, expired or invalid.
  • Bank authentication failed or abandoned.
  • Provider unavailable or returning an error.
  • Browser closed or refreshed during payment.
  • Session expired before payment completed.

3. Prove that one purchase cannot become two charges

Duplicate charges are among the most damaging payment defects, because the customer notices them immediately. They are often caused by ordinary behavior: double-clicking the pay button, refreshing the page, opening checkout in two tabs, or retrying after a slow response.

The most important case is a timeout. The customer submits a payment, the provider processes it successfully, but the response never reaches the application. The customer sees an error and pays again. Unless the system is designed for this, the customer has now been charged twice.

Payment state is not simply "success" or "failure". Ask the development team how the application handles an unknown outcome. A common approach is an idempotency key, a unique identifier sent with each payment request so the provider recognizes a repeated request and does not charge twice. Disabling the button helps the interface, but it does not protect the server from a repeated API request, so test both.

4. Test webhooks as unreliable messages

Webhooks often decide whether an order is fulfilled or a subscription is activated, yet they are easy to overlook because no one sees them. Providers generally deliver webhooks at least once, so the same event can arrive more than once, arrive late, or arrive in a different order from the one you expect.

Send duplicate, delayed and out-of-order events in the test environment and confirm that the outcome is still correct. One successful-payment event received twice must not create two orders or extend a subscription twice. Also test what happens when your application is unavailable when an event is sent, and confirm the provider's retries are processed correctly once it recovers.

Webhooks are usually signed by the provider. Check that the application rejects an event with an invalid or missing signature rather than trusting any request sent to that address.

  • Successful, failed and duplicate events.
  • Events received late or out of order.
  • Events sent while the application is unavailable.
  • Events with an invalid signature.

5. Check refunds, subscriptions and amounts separately

Refunds follow different logic from payments and deserve their own tests. Cover full refunds, partial refunds, several partial refunds against one payment, and refunds that fail. If a $100 payment receives a $40 refund, the provider, the database, the customer's history and the admin panel should all show $100 paid, $40 refunded and $60 remaining. A second refund should not be able to exceed the remaining balance.

Subscriptions add time to the problem. Test trials, renewals, failed renewals, expired cards, cancellations, upgrades, downgrades and any grace period. A common defect is a mismatch between payment status and access: a renewal fails, but premium access continues indefinitely, or a successful renewal does not restore access. The correct behavior depends on your business rules, so write those rules down before testing.

Check amounts at every step, not only at checkout. A $19.99 product should appear as $19.99 on the checkout page, in the request sent to the provider, in the database, on the receipt and in refund calculations. Include taxes, discounts, rounding, minimum and maximum amounts, and each supported currency.

6. Treat security and access as part of payment testing

Card data carries specific obligations. The Payment Card Industry Data Security Standard (PCI DSS) sets requirements for organizations that store, process or transmit cardholder data, and version 4.0.1 is the current version. Using a provider's hosted payment page or embedded payment fields usually keeps card numbers away from your servers and reduces, but does not remove, your obligations. Confirm your responsibilities with your payment provider and, where needed, a qualified assessor.

QA should check that payment details do not appear where they should not: in URLs, application logs, error messages, API responses, analytics events, screenshots or exported reports. Scripts loaded on the payment page also deserve attention, since PCI DSS includes requirements for managing them.

Authorization belongs in the same test plan. A customer should not be able to open another customer's invoice by changing an ID in the address bar or API request. Admin actions such as issuing refunds should be limited to the roles that need them and recorded in an audit trail.

Common mistakes to avoid

Many payment defects reach production because the test plan only covered the path a demo would show. The checkout looks correct, while the records behind it disagree.

  • Testing only successful payments.
  • Checking the confirmation screen but not the order, access or reports.
  • Ignoring double clicks, refreshes and retries after a timeout.
  • Leaving webhooks out of the test plan.
  • Assuming partial refunds work because full refunds do.
  • Treating a successful provider transaction as proof the business outcome is correct.

What to agree before payment development starts

Describe the payment journeys the product needs: one-time purchases, subscriptions, refunds, invoices, currencies and the regions you sell in. Write down business rules for failed renewals, cancellations and refunds, and decide who can issue a refund from the admin panel.

Ask your development partner to include these scenarios in the acceptance criteria and to demonstrate them in a test environment before launch: a declined card, a retry after a timeout, a duplicate webhook, a partial refund and a failed renewal. Code Huddle's ParkingHub case study describes a parking SaaS platform with connected customer workflows; it shows the type of product in which payment, access and records must stay aligned, and it is not presented as a testing benchmark. A clear test plan agreed early is less costly than reconciling incorrect charges after launch.

Continue reading

Is your web app slow? Don’t buy a bigger server yet

By Kashif Abbas KazmiDiagnose a slow web app before upgrading hosting: measure user journeys, database queries, connection pools, payloads, background jobs, and caching.

Software project handover: a checklist for changing development teams

By Haris AhmedPlan a software handover with clear repository access, deployment instructions, data ownership, integration accounts, tests, operating costs, and release responsibilities.

How to compare software development proposals

By Haris AhmedCompare software development estimates using scope, assumptions, integrations, acceptance criteria, ownership, and operating costs—not just the headline price.

How to scope an AI integration project

By Haris AhmedA practical buyer’s guide to AI integration: define the workflow, data permissions, evaluation, operating costs, delivery scope, and handover before commissioning a build.

Planning a bilingual news website and editorial CMS

By Haris AhmedPlan English–Urdu publishing, RTL layouts, editorial permissions, story URLs, media, and distribution, with concrete examples from Code Huddle’s QOM News project.

How to Choose a Tech Stack for Your Web App and the Mistakes to Avoid

By Muhammad SarimLearn how to choose the right tech stack for your web app. Compare frontend, backend and database options, and avoid costly mistakes.

How to Manage Client Requirements Without Losing Control of the Project

By Noor Ul HudaA Project Manager’s guide to clarifying requests, preventing scope creep, documenting decisions, and managing client requirements without losing control of the project.

Who Moderates the Moderation AI?

By Minahil AliCan AI handle content moderation on its own? Learn how moderation models work, how to set thresholds, when humans step in, and the mistakes to avoid.

Testing AI-Powered Applications: A QA Engineer’s Practical Guide

By Aymen HameedHow QA can test AI-powered products for accuracy, consistency, uncertainty, end-to-end outcomes, regression coverage, and post-release learning.

How to Deploy a NestJS App to AWS EC2 with GitHub Actions (Without Building on the Server)

By Abdur RehmanBuild NestJS in GitHub Actions, ship a ready-to-run archive to EC2, reload with PM2, and roll back automatically if a health check fails.

The AI-Powered Developer Workflow: From Planning to Code Review and Deployment

By Salis Bin SalmanUse AI across your whole development process without shipping wrong code. A 6-stage workflow for planning, coding, testing, code review and deployment.