Guides
Test mode and test cards
A test key touches test data only, and the test provider takes a token instead of a card.
Every key is for one mode. A rt_test_ key reads and writes test data; a rt_live_ key would read and write live data. The two never mix: an event made in test mode does not exist in live mode, and the same ids are different records.
What is different in test mode#
- Emails and texts a test order sends are marked
[Test]in the subject or the text, so nobody takes one for a real ticket. On this host mail stays in an outbox and texts go to a fake provider, so nothing reaches a real person;GET /v1/test_helpers/smsreads the texts. - Where mail is switched on, test-mode mail reaches only members of your organization, however the order was made: a key, the kit or a hosted link. So does every other test-mode mail: a transfer offer, a My tickets code, a partner's page. Anything to another address stays in the outbox, and nothing tells the sender: the call still answers as usual, and the kit's confirmation still says the tickets were sent. To test by mail, use the address of someone on your team. To read what would have gone to anyone else, and why it stayed, call
GET /v1/test_helpers/mail?to=<address>. Sendnotify: { email: false }to make no mail at all. A hosted link'sTickets-Mailheader saysofffor an address that won't hear. Payment tokens answer the same on both. - Payments use the
testprovider, which charges no card. Anexternalpayment is recorded as given, as in live mode. - You can set the time something happened with
aton a hold or an order (it must not be before the hold was made), so a report has history to show. - A few helpers exist only here: expire a hold now, read the texts that would have gone out, and delete all of the org's test data.
- Webhooks, the event log, the SDK and the MCP server work as they will in live mode.
The test provider#
Send a token instead of a card: payment: { provider: 'test', token }. The token decides what happens.
| Token | What happens | The kit's test card |
|---|---|---|
tok_success | The payment succeeds. The order is paid. | 4242 4242 4242 4242 |
tok_decline | The card is declined: 402 payment_declined, decline_code card_declined. | 4000 0000 0000 0002 |
tok_insufficient | Declined for funds: 402 payment_declined, decline_code insufficient_funds. | 4000 0000 0000 9995 |
tok_error | The processor fails after about 1.5 seconds: 402 payment_failed. Nothing was charged. | 4000 0000 0000 0119 |
tok_dispute | The payment succeeds, then a minute later the processor opens a dispute and the order's tickets freeze. | none |
In the kit's card form each test card is a button (Works, Declined, Not enough funds, Processor error) that fills the number; the number in the box is what is sent, however it got there, and one that is not on this list is refused before any call.
A card answer takes a quarter to half a second, as a real one does. The test provider works with a test key only; with a live key the order answers provider_unavailable.
A declined payment does not use up the hold. It stays active until its clock ends, so the buyer can try another card on the same hold:
import { TicketsError } from '@rcmstickets/sdk';
const attempt = await tickets.holds.create({ event, items: [{ ticket_type: ga, quantity: 1 }] });
const buyer = { name: 'Maria Delgado', email: 'maria@example.com' };
try {
await tickets.orders.create({ hold: attempt.id, buyer, payment: { provider: 'test', token: 'tok_decline' } });
} catch (error) {
if (!(error instanceof TicketsError)) throw error;
console.log(error.status, error.code, error.declineCode); // 402 payment_declined card_declined
}
const second = await tickets.orders.create({ hold: attempt.id, buyer, payment: { provider: 'test', token: 'tok_success' } });
console.log(second.status); // paidHelpers#
POST /v1/test_helpers/holds/{id}/expireends a hold now, as the sweeper would, so you can see what your checkout does when the clock runs out. Test keys only (test_mode_onlyotherwise).GET /v1/test_helpers/smslists the texts the fake provider has "sent" to a number.GET /v1/test_helpers/mail?to=<address>lists the mail test mode made for an address, newest first: its subject and text, andheld_whywhen it stayed in the outbox (test_mode_not_a_member,daily_cap, ormail_is_offon this host). Needs a full key, or an owner or admin.POST /v1/test_helpers/resetdeletes all of the org's test data (events, orders, tickets, holds, codes). It runs as a job. Keys, webhook endpoints, integrations, the team and any platform fee rate stay. Its body says it on purpose, so it is never sent by accident:
{ "confirm": "delete test data" }const short = await tickets.holds.create({ event, items: [{ ticket_type: ga, quantity: 1 }] });
const gone = await tickets.testHelpers.expireHold(short.id);
console.log(gone.status); // expiredSquare's sandbox#
The square provider charges a card token from Square's Web Payments SDK on the organization's connected Square account. In test mode it uses Square's sandbox and its published test tokens.