Try it with test cards

Run a whole payment in a sandbox project with Stripe's test cards and a virtual charger, with no real money moving.

2 min readEdit this page
On this page

A sandbox project runs the same flow as a live one against Stripe's test mode, so a whole payment can be rehearsed with no real money. Nothing a sandbox project does touches live money.

What to use

  • A sandbox project and a sandbox API key (flw_ak_test_...) that holds settlement.payment.hold. See projects. A sandbox key reaches sandbox chargers only, and a sandbox project asking for real money is refused with accountNotReady.

  • A virtual charger, so no hardware is needed. Set its access to Paid.

  • Stripe's published test cards, typed into the Payment Element with any future expiry and any three-digit security code:

Card numberWhat happens
4242 4242 4242 4242The hold is authorized with no extra step
4000 0025 0000 3155The bank asks for approval first (3-D Secure)
4000 0000 0000 9995The card is declined

Real cards do not work in test mode.

A run

  1. Ask for a hold, confirm it with 4242 4242 4242 4242, and read the hold until it says authorized.

  2. Start the session, and see the virtual charger take it.

  3. Stop it, wait for captured, and read the receipt. It shows what was taken, and the rest was released.

  4. Do it again with 4000 0025 0000 3155, and complete the approval step.

  5. Do it once more with 4000 0000 0000 9995. Stripe's decline shows in your page, and the hold reads declined; a start under it is refused with holdNotAuthorized.

  6. Ask for a hold, confirm it, wait six minutes without starting, and see windowEnded when you try.

Before you go live

Switch the project's API key to a live one. Nothing else in your code changes except the keys: the publishable key comes from the answer to the hold, so a live hold hands your page the live one.