Interactive local test
Test a funding response
Choose a mock response, then inspect what the checkout should show. Try a late response to see why the selected card must keep its own result.
Selected fixture: None
Funding: unknown · Source: idle
Choose a case and run it to compare the observed state with its expected result.
Invented adapter responses for offline UI tests. IDs are local fixtures, not real provider tokens. No funding type is inferred from a generated PAN.
Inspect the current JSON
Enable JavaScript to inspect a changed state. The fixed cases and downloadable tests are documented below.
A funding response is a separate input
A card number supplies form data; a funding response supplies metadata. This demo exercises the second part with invented adapter responses. It does not accept a PAN, contact an issuer or label a generated number as debit. For number and expiry fields, use the full card generator linked above or the Maestro form tests.
Choose a mock and select Run selected case. The observed funding and source appear next
to the expected result. Changing the case or resetting clears the previous result. The
source field is this example’s explanation of where a result came from, not a provider field.
| Mock input | Expected state | Defect this catches |
|---|---|---|
card.funding is debit, credit or prepaid | Preserve that value; source reported | Collapsing distinct product types into debit |
Provider reports unknown | Unknown; source reported | Treating a supported enum as an exception |
Missing card data or unexpected DEBIT value | Unknown; source missing | Guessing a classification from incomplete data |
| Lookup rejects | Unknown; source unavailable | Retaining the previous card’s classification |
| A finishes after B was selected | B stays credit; source reported | A stale response relabeling the current card |
The selected labels are local mocks. Stripe documents funding values on a PaymentMethod’s card object, but this small adapter is not an implementation of that API. Map your provider’s actual response and identifier before using the example in an application.
Step through an out-of-order response
- Select either Delayed card A case and run it. A is selected, its lookup is held pending,
and the old funding label is cleared to
unknown / loading. - Choose Next: select card B. B completes immediately as
credit / reported, while A is still pending. - Release or fail A with the next button. The late result must leave B’s selection and funding unchanged. The visible event list records the sequence.
Both successful and failed late responses matter: a stale failure must not erase B’s good result any more than a stale success should replace it. You can change the selected case or reset between steps; abandoned responses cannot update the new view.
This is a deterministic local sequence, not a timed network request. The lookup-failure case rejects a promise; it does not configure a real timeout. Add timeouts and cancellation to your actual integration according to its requirements. The revision counter below protects displayed state without canceling the underlying request.
Inspect and reuse the result
Copy test result (JSON) includes the selected case, fixture ID, observed state, expected state and event list. It is a local test record, not a provider request or a usable payment method. It contains no card number. The demo keeps state in memory and does not upload it.
Download the complete funding and wallet test project , extract it and run with Node.js 22 or later:
node --test debit-funding.test.mjs virtual-wallet.test.mjs
The browser and downloadable tests both import this implementation:
async function readFunding(paymentMethodId, lookup) {
try {
const response = await lookup(paymentMethodId);
const funding = response?.card?.funding;
return ['debit', 'credit', 'prepaid', 'unknown'].includes(funding) ?
{ funding, source: 'reported' } : { funding: 'unknown', source: 'missing' };
} catch {
return { funding: 'unknown', source: 'unavailable' };
}
}
function createFundingView() {
let revision = 0;
let selectedId = null;
let state = { funding: 'unknown', source: 'idle' };
return {
current: () => ({ ...state }),
selected: () => selectedId,
reset() {
revision += 1;
selectedId = null;
state = { funding: 'unknown', source: 'idle' };
},
async select(paymentMethodId, lookup) {
const request = ++revision;
selectedId = paymentMethodId;
state = { funding: 'unknown', source: 'loading' };
const result = await readFunding(paymentMethodId, lookup);
if (request === revision) state = result;
}
};
}Replace lookup with a controlled adapter around your own server code, retaining the
fixture responses and assertions. The suite checks enum mapping, missing data, failure,
late success, late failure and resetting while a lookup is pending. These are local
regressions; passing them does not verify a provider account or a real funding classification.
Keep classification and business decisions separate
If your product has a debit-only feature, specify what it does for credit, prepaid, unknown and unavailable results. The demo does not calculate fees, select a retry policy, infer a balance or decide whether a payment is permitted. Those decisions need separate requirements.
A prefix can suggest a configured network. It cannot replace a maintained account-range or provider data source. The BIN/IIN prefix analyser deliberately reports no issuer or funding metadata; the BIN guide explains provenance.
Use a stable application or provider identifier for selected cards. The
virtual-wallet demo shows why matching last-four values
cannot serve as that identifier. For authorizations, declines or partial approvals, use
provider test fixtures with the correct request configuration rather
than expecting a local funding label to trigger a gateway outcome.