When a test payment fails, first identify which component produced the result. A local validation error, a misconfigured sandbox, an authentication request and a provider decline require different fixes. Replacing the card number repeatedly can hide the original problem and create additional attempts.
Use this guide as a debugging path for your own authorized integration. The downloadable cases make no payment requests and never test whether a real account exists.
Identify the failing boundary
| Evidence | Likely boundary | Useful next observation |
|---|---|---|
| Form rejects input before submission | Input contract | Original string, supported length and checksum result using synthetic data |
| API reports wrong credentials or environment | Integration configuration | Account, endpoint and key mode; redact the actual secret |
| Provider requests customer action | Authentication | Current payment state and supported next action |
| Provider returns an explicit decline | Provider decision | Documented error category and permitted recovery |
| Connection closes without a definitive result | Transport uncertainty | Existing payment lookup and server event history |
| Payment is authorized but unfulfilled | Capture/order workflow | Capture status, server order match and fulfillment job |
These boundaries are not a fixed four-step network pipeline. Providers and payment methods combine them differently. Treat your normalized application categories separately from raw provider error codes.
Check the fixture and environment together
Start with the provider’s published fixture and the intended product. A PayPal wallet flow, Expanded Checkout and Braintree sandbox have different setup and trigger rules. The cross-provider reference links the relevant documentation; the PayPal guide tests capture interpretation.
For Stripe, inspect the selected account/sandbox, test credentials, webhook destination and the particular scenario. A malformed expiry may fail input validation before a decline fixture reaches the path you intended. A successful local checksum does not correct a wrong API key or enable an unsupported payment method. Use Stripe’s sandbox testing use cases to validate the configured integration.
Keep synthetic local data separate from provider fixtures. Our bulk tool can intentionally generate invalid-checksum records. Our local profile supports lengths from 12 to 19 across its configured networks, but your provider may support a narrower set. The generator does not query issuer accounts and cannot certify that an arbitrary value is unassigned.
Choose an action from evidence
export function paymentNextStep(signal) {
// Application-normalized categories, not raw error codes shared by all gateways.
const actions = {
'invalid-input': 'correct-input', 'wrong-environment': 'fix-configuration',
'action-required': 'complete-provider-authentication',
'provider-decline': 'follow-provider-decline-guidance',
'transport-unknown': 'reconcile-existing-payment',
'authorized': 'capture-under-server-policy', 'pending': 'wait-for-server-state',
'paid': 'check-fulfillment-record'
};
return Object.hasOwn(actions, signal) ? actions[signal] : 'review';
}| Case | Input / condition | Expected result |
|---|---|---|
| invalid-input | Local validator rejects the input | "correct-input" |
| wrong-environment | Test fixture configured against live mode | "fix-configuration" |
| transport-unknown | Request timed out after submission; result unknown | "reconcile-existing-payment" |
| action-required | Provider requests authentication | "complete-provider-authentication" |
| authorized | Manual capture has not happened | "capture-under-server-policy" |
| provider-decline | Provider explicitly reports a decline | "follow-provider-decline-guidance" |
transport-unknown deliberately maps to reconcile-existing-payment. It does not create a new charge. Keep the provider payment identifier associated with the server order, retrieve trusted state through your authorized integration and handle retries according to that provider’s idempotency semantics.
authorized points to the server capture policy, not an instruction for a browser to capture blindly. provider-decline requires the documented recovery for the actual error; some circumstances need a different method or customer action. The function is a teaching decision table, not a universal decline-code mapper.
Reproduce two misleading success reports
Authentication completed, payment failed: use the documented authenticate-then-decline sandbox scenario from the 3DS guide. The challenge can finish successfully while the application must still offer another payment method. Record the final payment and order states, not just the challenge result.
Provider succeeded, browser timed out: delay the browser response while allowing the verified server observation to update the order. Returning to the order page should display its stored result. The Stripe regression project demonstrates order matching and one durable fulfillment job under repeated delivery.
A database truncation can also corrupt a fixture before submission. Store identifiers as strings and inspect your database’s actual constraints and error mode; a short column does not silently truncate in every database/configuration. The Visa transport example covers a separate problem: JavaScript number precision can change long identifiers before storage.
Record a useful bug report
Include the test environment and product, application/SDK version, scenario name, expected state, observed state and provider request/event identifier. Use synthetic fixture labels in public reports. Exclude raw request bodies, API secrets, PANs, security codes and customer details from routine telemetry; the CVV guide demonstrates allowlisted outputs.
Do not use a generic “small live charge, then refund” instruction as a release test. Stripe’s testing documentation expressly prohibits testing live mode with real payment details. Follow your provider’s current readiness procedure and keep controlled sandbox checks separate from genuine authorized commerce.
Run the diagnostic cases
Download the shared diagnostic fixtures , extract and use Node.js 22 or later:
node guide-demo.mjs failure
node --test guide-examples.test.mjs payment-guide-examples.test.mjs
Passing these cases proves that the displayed input categories choose the documented actions. It does not prove your API credentials, account capabilities or payment integration are configured correctly. Keep those checks in the sandbox test record alongside the local regression results.
The linked Stripe testing and environment guidance were last checked against provider documentation on . Providers do change what they publish — the official link beside each claim is authoritative.