Most payment bugs don't look like bugs. The checkout works, the demo card goes through, and the release ships. Then a customer is charged twice, a refund never reaches their bank, or an order stays "pending" because one webhook arrived before another.
These failures cost more than a broken button. They turn into chargebacks, support tickets and lost trust, and they are hard to reproduce after the fact.
This checklist is the one our QA engineers start from when we test payment flows for e-commerce, subscription and fintech products. It covers three areas where we see the most defects: card payments, refunds and webhooks. Copy it into your test plan and cut what doesn't apply to your provider.
A typical failure we look for
Picture a subscription app. On Friday a renewal charge is declined, and the provider sends a
payment_failedevent. The app's webhook endpoint is slow during a deploy and times out, so the provider keeps that event for a retry. On Saturday the provider retries the card, the charge succeeds and the account is marked paid. Then the delayed Friday event finally arrives. The app trusts whichever event came last and locks the account.The customer has been charged and can't log in. Support sees a paid invoice and a locked user. On staging the events always arrive in order, so nobody can reproduce it. Every piece of this is in the checklist below: retries, event order and reconciliation. A happy-path test suite passes it; a customer finds it.
Before you start: what to set up
- A sandbox account with your payment provider. Stripe, PayPal, Adyen and most others offer one with test cards and test webhooks. Never test with real card numbers outside production.
- The provider's test card list. Each provider publishes cards that trigger specific results: success, decline, insufficient funds, 3D Secure challenge, expired card. Stripe's list is a good example (Stripe testing docs).
- Access to logs and the provider dashboard. Many payment checks are only visible there: the event that was sent, the retry count, the amount actually captured.
- A way to receive webhooks locally or on staging. A provider CLI or a tunnel works. Without it you can't test the most fragile part of the flow.
- Your business rules in writing. Which currencies you accept, when you capture, who can refund, and how long an order may stay unpaid. Most payment bugs are gaps between these rules and the code.
1. Card payments checklist
Start with the happy path, then spend most of your time on everything else. In our experience the happy path is rarely where the defects are.
| Area | What to check | Example (Stripe test mode) |
|---|---|---|
| Successful payments | • Payment succeeds with each card brand you accept (Visa, Mastercard, Amex, Discover) • The amount charged equals the amount shown at checkout, including tax, shipping and discounts • Currency and rounding are correct for every currency you sell in, including zero-decimal currencies such as JPY • The order, invoice and confirmation email show the same amount and the same last four digits • Saved cards work for repeat purchases, and the customer can remove a saved card |
Visa 4242 4242 4242 4242, Mastercard 5555 5555 5555 4444, Amex 3782 822463 10005, Discover 6011 1111 1111 1117. Then a JPY order: amount: 500 must mean ¥500. |
| Declines and errors | • Generic decline, insufficient funds, expired card, wrong CVC and wrong ZIP each show a clear message to the customer • The message doesn't reveal fraud rules or raw provider error codes • After a decline the customer can retry with another card without refilling the whole form • A declined payment never creates a paid order or reserves stock forever • Provider timeouts and 5xx errors show a safe "we're checking your payment" state, not a success or a failure |
4000 0000 0000 0002 generic decline, …9995 insufficient funds, …0069 expired card, …0127 wrong CVC (send a CVC, or the check is skipped). |
| 3D Secure and authentication | • A card that requires 3D Secure opens the challenge on desktop and mobile, including in-app browsers • Passing the challenge completes the payment; failing or closing it leaves the order unpaid • The customer returns to the right page after the challenge, with the cart intact |
4000 0027 6000 3184 asks for authentication on every payment: pass the challenge, fail it, then close the window. |
| Double charges and race conditions | • Double-clicking "Pay" or pressing it twice on a slow network charges once • Refreshing the page or pressing Back during payment doesn't create a second charge • Two tabs with the same cart can't both be paid • Requests to the provider use idempotency keys, so a retried request doesn't charge again |
Throttle the network to Slow 3G and double-click Pay. Send the same request twice with one Idempotency-Key: both replies must hold the same payment ID. |
| Authorization and capture | • If you authorize first and capture later, capture happens at the right moment (shipment, booking date, trial end) • Partial capture works if you support it, and the uncaptured rest is released • Authorizations that expire before capture are handled, not silently lost |
Create the payment with capture_method: manual, then capture a smaller amount_to_capture. An online card authorization usually expires after 7 days. |
| Subscriptions (if you have them) | • Trial end, first charge, renewal, upgrade, downgrade and proration give the right amounts • A failed renewal triggers the retry schedule and the customer notice you defined • Cancellation stops future charges and keeps access until the end of the paid period, if that is your rule |
Use a billing test clock to move time past the trial end and the first renewal instead of waiting for real dates. |
2. Refunds, voids and chargebacks checklist
Refunds get far less testing than checkout, because nobody demos them. They are also where money and records drift apart.
| Area | What to check | Example (Stripe test mode) |
|---|---|---|
| Full and partial refunds | • A full refund returns the exact amount charged, in the original currency • Partial refunds work, and the sum of all refunds can never exceed the original charge • Refunding one item from a multi-item order recalculates tax, discounts and shipping by your rules • Refunds paid with a gift card, store credit or a mix of methods go back to the right places |
Charge $50, refund $30, then try another $30: the second refund must be rejected and the order must not change. |
| Voids versus refunds | • Cancelling before capture voids the authorization instead of charging and refunding • Cancelling after capture triggers a refund, and the order status reflects which one happened |
Cancel a manual-capture payment before capture: it ends as canceled with no refund record. |
| Permissions and limits | • Only the roles you allow can issue refunds, and the API enforces it, not just the UI • Large refunds or refunds after a set number of days need the approval you defined • Every refund is logged with who issued it, when and why |
Call the refund endpoint with a support-agent token instead of an admin one: expect 403, and nothing in the logs as refunded. |
| Failure cases | • A refund the provider rejects (card closed, refund window passed) shows a clear error and leaves the order unchanged • Clicking "Refund" twice refunds once • A refund started in your admin and one started in the provider dashboard both end up in your records |
Send two refund requests for the same order at the same moment: exactly one may succeed. |
| Downstream effects | • Stock, loyalty points, licenses and access are returned or revoked as your rules say • The customer gets a refund email with the correct amount and an honest time estimate • Accounting exports and reports show the refund in the right period |
Refund one of two items: stock goes up by one, its loyalty points are removed, the email shows that item's amount. |
| Chargebacks and disputes | • A dispute opened at the provider reaches your system and flags the order • Won and lost disputes update the order and your balance correctly • Evidence your team needs (receipt, delivery proof, logs) is available for the order |
Pay with 4000 0000 0000 0259 to open a fraudulent dispute and follow it through your order, balance and evidence screens. |
3. Webhooks checklist
In most modern payment flows the browser redirect is only a hint. The real answer about whether money moved comes later, in a webhook from the provider. That makes webhooks the most important and the least tested part of the flow.
Providers deliver webhooks at least once, not exactly once. They retry on errors and timeouts, and they don't promise order. Your code has to survive all of that.
| Area | What to check | Example (Stripe test mode) |
|---|---|---|
| Security | • Every webhook's signature is verified, and unsigned or wrongly signed requests are rejected • Old events replayed outside the allowed time window are rejected • The endpoint doesn't trust amounts or statuses from the payload without checking them against the provider when it matters • The endpoint responds within the provider's timeout and does heavy work in the background |
Change one byte of the body, or replay an event with an old Stripe-Signature timestamp: expect 400. Stripe libraries allow 5 minutes by default. |
| Duplicates and retries | • The same event delivered twice changes the order once (store and check the event ID) • If your endpoint returns an error, the provider retries and the retry is processed correctly • After a long outage, a backlog of retried events is processed without double fulfillment or lost orders |
Run stripe events resend <event_id> twice for the same event: the order changes once. |
| Order of events | • A "payment succeeded" event that arrives before "payment created" doesn't break the order • A refund event that arrives before your own refund call returns is handled once • A late "failed" event can't overwrite a newer "succeeded" status |
Make your endpoint return 500 for payment_intent.created once, so its retry arrives after payment_intent.succeeded. |
| Coverage of event types | • Every event type you subscribe to has a handler, and unknown types are logged and ignored safely • Success, failure, refund, dispute, subscription renewal and payment method update events are each tested end to end • Switching from test mode to live mode uses the live signing secret and the live endpoint |
stripe listen --forward-to localhost:4242/webhook, then stripe trigger each event type you handle. |
| Reconciliation | • A daily job or report compares your orders with the provider's records and flags mismatches • Orders stuck in "pending" longer than your limit raise an alert • Someone on the team knows what to do when the alert fires |
On staging, delete one order row that has a payment: the next reconciliation run must flag it. |
4. Security and compliance checks
Payment pages are a favorite target, so functional testing isn't enough. We check payment flows against the OWASP Top 10 and against the PCI DSS rules that apply to the product.
- Full card numbers and CVC never appear in your logs, analytics, error trackers or support tools
- Card fields are hosted by the provider (iframe or hosted page), so card data doesn't touch your servers unless you intend it to
- Prices, discounts and currency can't be changed by editing the request from the browser
- One customer can't see or refund another customer's payments by changing an ID in the URL or API
- Coupon and gift card codes can't be brute-forced or reused beyond their limits
- Payment and refund endpoints have rate limits
5. What to automate first
You don't need to automate the whole list. Payment tests that run on every release pay off fastest in three places:
- API tests for charge, refund and webhook handling. They are fast, stable and catch most money bugs. Run them against the provider's sandbox in CI. See our API testing approach.
- A few end-to-end checkout tests. One success, one decline and one 3D Secure flow per main platform is usually enough. More UI tests add maintenance, not safety. See test automation.
- A smoke check in production. A small real payment and refund on a schedule, or a check that recent orders match provider records, tells you within minutes when something breaks.
Keep exploratory testing for new payment methods, new countries and anything that touches money for the first time. Those are the releases where the checklist above finds the most.
6. Examples: payment tests in Playwright and Postman
Below are short examples of the checks above, written against Stripe's test mode. The same ideas work with PayPal and Adyen sandboxes; only the API calls change. Use a test-mode key (sk_test_...), keep it in CI secrets, and never point these tests at a live account.
Card payments and refunds with Playwright and TypeScript. Playwright's test runner works well for API tests, not just the browser. Here it calls the provider directly with Stripe's official Node library and test payment methods such as pm_card_visa and pm_card_chargeDeclined.
Show code: card payments and refunds (Playwright)
import { test, expect } from '@playwright/test';
import Stripe from 'stripe';
// Test-mode key only (sk_test_...). Never run these against a live key.
const stripe = new Stripe(process.env.STRIPE_TEST_SECRET_KEY!);
test.describe('card payments', () => {
test('successful card payment charges the exact amount', async () => {
const pi = await stripe.paymentIntents.create({
amount: 4999, // $49.99 in cents
currency: 'usd',
payment_method: 'pm_card_visa', // Stripe test card
automatic_payment_methods: { enabled: true, allow_redirects: 'never' },
confirm: true,
});
expect(pi.status).toBe('succeeded');
expect(pi.amount_received).toBe(4999);
});
test('declined card returns card_declined and no charge', async () => {
const err = await stripe.paymentIntents
.create({
amount: 4999,
currency: 'usd',
payment_method: 'pm_card_chargeDeclined',
automatic_payment_methods: { enabled: true, allow_redirects: 'never' },
confirm: true,
})
.catch((e) => e);
expect(err).toBeInstanceOf(Stripe.errors.StripeCardError);
expect(err.code).toBe('card_declined');
});
test('retry with the same idempotency key does not charge twice', async () => {
const params: Stripe.PaymentIntentCreateParams = {
amount: 4999,
currency: 'usd',
payment_method: 'pm_card_visa',
automatic_payment_methods: { enabled: true, allow_redirects: 'never' },
confirm: true,
};
const idempotencyKey = `order-${Date.now()}`;
const first = await stripe.paymentIntents.create(params, { idempotencyKey });
const retry = await stripe.paymentIntents.create(params, { idempotencyKey });
expect(retry.id).toBe(first.id);
});
});
test.describe('refunds', () => {
test('partial refunds can never exceed the charge', async () => {
const pi = await stripe.paymentIntents.create({
amount: 5000,
currency: 'usd',
payment_method: 'pm_card_visa',
automatic_payment_methods: { enabled: true, allow_redirects: 'never' },
confirm: true,
});
const partial = await stripe.refunds.create({ payment_intent: pi.id, amount: 3000 });
expect(partial.status).toBe('succeeded');
// Only $20.00 is left; asking for $30.00 more must be rejected.
await expect(
stripe.refunds.create({ payment_intent: pi.id, amount: 3000 }),
).rejects.toBeInstanceOf(Stripe.errors.StripeInvalidRequestError);
});
});
Webhooks with Playwright. These tests send signed events to your own staging endpoint, the way the provider would. They check that a bad signature is rejected and that a duplicate event doesn't fulfill an order twice. The /api/test/orders route is a placeholder for whatever test-only way your team has to read an order's state.
Show code: webhooks (Playwright)
import { test, expect } from '@playwright/test';
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_TEST_SECRET_KEY!);
const secret = process.env.STRIPE_WEBHOOK_SECRET!; // whsec_... of your staging endpoint
const WEBHOOK_URL = '/webhooks/stripe'; // your endpoint, relative to baseURL
// Build a signed event the same way Stripe does.
function signedEvent(event: object) {
const payload = JSON.stringify(event);
const signature = stripe.webhooks.generateTestHeaderString({ payload, secret });
return { payload, signature };
}
// A real test-mode payment, so a handler that re-fetches the PaymentIntent from Stripe finds it.
// Use the id of an order your test data already has.
let event: object;
test.beforeAll(async () => {
const pi = await stripe.paymentIntents.create({
amount: 4999, currency: 'usd', payment_method: 'pm_card_visa', confirm: true,
automatic_payment_methods: { enabled: true, allow_redirects: 'never' },
metadata: { orderId: 'test-order-1' },
});
event = {
id: `evt_test_${Date.now()}`, // fresh id each run, so the duplicate check starts clean
object: 'event',
type: 'payment_intent.succeeded',
data: { object: pi },
};
});
test('rejects a webhook with a bad signature', async ({ request }) => {
const res = await request.post(WEBHOOK_URL, {
headers: { 'stripe-signature': 't=1,v1=bad', 'content-type': 'application/json' },
data: JSON.stringify(event),
});
expect(res.status()).toBe(400);
});
test('the same event delivered twice is processed once', async ({ request }) => {
const { payload, signature } = signedEvent(event);
const headers = { 'stripe-signature': signature, 'content-type': 'application/json' };
const first = await request.post(WEBHOOK_URL, { headers, data: payload });
const duplicate = await request.post(WEBHOOK_URL, { headers, data: payload });
expect(first.ok()).toBeTruthy();
expect(duplicate.ok()).toBeTruthy(); // acknowledge it, but do nothing
// Check your own system: one paid order, one fulfillment.
const order = await (await request.get('/api/test/orders/test-order-1')).json();
expect(order.status).toBe('paid');
expect(order.fulfillments).toHaveLength(1);
});
Refund checks in Postman. If your team already keeps API collections in Postman, add assertions to the request's Tests tab and run the collection in CI with Newman: newman run payments.postman_collection.json -e sandbox.postman_environment.json.
Show code: refund checks (Postman)
// Tests tab of "POST {{baseUrl}}/v1/refunds" (Stripe test mode)
// Body (x-www-form-urlencoded): payment_intent={{paymentIntentId}}, amount={{refundAmount}}
pm.test('refund succeeded', () => {
pm.response.to.have.status(200);
const refund = pm.response.json();
pm.expect(refund.status).to.eql('succeeded');
pm.expect(refund.amount).to.eql(Number(pm.collectionVariables.get('refundAmount')));
});
pm.test('refund is linked to the right payment', () => {
const refund = pm.response.json();
pm.expect(refund.payment_intent).to.eql(pm.collectionVariables.get('paymentIntentId'));
});
Start with these five or six tests, run them on every merge, and add one test each time a payment bug reaches staging. After a few months the suite covers the cases that actually break in your product.
7. Using AI and MCP tools to draft payment tests
AI assistants can speed up the first draft of these tests. Three tools we find useful for payment flows, all with official MCP servers or built-in AI:
-
Playwright MCP (
@playwright/mcp, by Microsoft) lets an AI assistant drive a real browser. Ask it to walk the checkout on staging with a test card, then turn the steps it took into a Playwright test you review and keep. -
Stripe MCP server (
mcp.stripe.com, or@stripe/mcplocally) lets the assistant create test-mode objects and search Stripe's docs. It is handy for setting up a payment, a refund or a dispute in test mode and checking the exact responses your tests should expect. - Postman MCP server and Postman's AI assistant can generate test scripts from a real response and build collections, which is a quick start for the refund and webhook checks above.
Coding assistants such as Claude Code or GitHub Copilot can then turn the checklist tables into test skeletons. Two rules matter more than the tool:
- Review every generated test. AI tends to write tests that pass, not tests that prove the rule. Check that each test fails when the bug is there.
- Use test-mode keys with limited permissions only. Never give an assistant a live key or real customer data.
From our projects
Two examples from our work, without client names:
- A booking platform in Australia. The API was tested by hand through the UI. We automated the API suite, including payment and refund flows with Stripe and PayPal, and ran the same suite on staging and production. Today 4,000+ automated API tests guard every booking. Read the case.
- An EdTech platform. Payment bugs were reaching users before the team saw them. We tested subscriptions, renewals and refunds with Stripe on every release as part of the regression suite. Read the case.
In both projects refunds were covered by tests alongside checkout, not left for manual spot checks.
FAQ
What should a payment testing checklist cover?
Card payments (successful payments, declines, 3D Secure, double charges, authorization and capture, subscriptions), refunds, voids and chargebacks, webhooks (security, duplicates, event order, reconciliation) and security checks such as keeping card data out of logs.
What is an idempotency key and why test it?
It is a unique key sent with a payment request. If the same request is retried with the same key, the provider returns the original result instead of charging again. Test it by sending the same request twice with one key and checking that both replies hold the same payment.
How do you test payment webhooks locally?
Forward events to your machine with a provider CLI or a tunnel. With Stripe, run stripe listen --forward-to followed by your local endpoint, trigger events with stripe trigger, and resend an event with stripe events resend to test duplicates.
Which test cards should we use?
Use the test cards your payment provider publishes for its sandbox, such as Stripe's 4242 4242 4242 4242 for a successful payment and 4000 0000 0000 0002 for a generic decline. Never test with real card numbers outside production.
Which payment tests should be automated first?
API tests for charge, refund and webhook handling, a few end-to-end checkout tests (one success, one decline, one 3D Secure flow per main platform) and a small smoke check in production.
Originally published on the Test Squad blog. Oleksandr Bobyr is a QA expert at Test Squad with more than 6 years in software testing.




Top comments (0)