Blog

November 4, 2026 · Ihor Stefaniv · 2 min read

Payment testing: test cards, 3-D Secure, refunds and double charges

Payments fail in expensive ways. How to test them safely in sandbox mode, the scenarios that matter most, and the bugs that cost real money.

Rule zero: never use real cards

Every major provider has a sandbox with published test card numbers — Stripe's 4242 4242 4242 4242, plus cards that simulate declines, insufficient funds and 3-D Secure challenges. Use those. The Luhn-valid numbers from a test data generator are for form validation only; a payment gateway will reject them.

Happy paths

  • Pay with each supported method: card, Apple Pay, Google Pay, PayPal, bank transfer.
  • 3-D Secure frictionless and challenge flows.
  • Saved card for returning customers.
  • Order confirmation, receipt email and the order record all match the amount charged.

Declines and errors

Scenario Expected
Card declined Clear message, order not created or marked unpaid, cart preserved
Insufficient funds Same, with a reason the user can act on
3-D Secure failed or abandoned No charge, user can retry
Expired card, wrong CVC Field-level error before submission where possible
Gateway timeout No double charge on retry; the order state is reconciled

Double charges — the expensive bug

  • Double-click "Pay".
  • Refresh during processing.
  • Back button after payment.
  • Network drop after the gateway charged but before your server got the response.

The protections to verify: the button disables after the first click, the API uses an idempotency key, and the order state is reconciled from the provider's webhook. Test them with parallel requests — see databases and race conditions.

Webhooks

  • Signature verification — unsigned or forged events are rejected.
  • Retries — the same event delivered twice changes nothing.
  • Out-of-order events (refund before capture notification) end in the correct state.
  • What the user sees while the webhook hasn't arrived yet.

Refunds and disputes

  • Full and partial refunds; multiple partial refunds up to the total.
  • Refund after a discount or gift card — the right amount returns to the right method.
  • Refund of a canceled subscription mid-period, if prorated.

Money math

  • Rounding: taxes and discounts per line vs. per order.
  • Currencies with no minor units (JPY) and with three (KWD).
  • Displayed amount equals charged amount — to the cent.
  • Sales tax / VAT by region.

Security and compliance

  • Card data never touches your servers if you use hosted fields (keeps you in PCI DSS SAQ A scope).
  • No full card numbers in logs, analytics or error messages.

The full API side is in the API testing checklist.

Read next