# Testing

Develop locally, test Turnstile and Stripe, and use a test venue.

## Developing locally

1. Turn on **Allow localhost** (*Localhost toestaan*) on the key. Then `http://localhost:<port>` and `http://127.0.0.1:<port>` work.
2. Serve your HTML through a local web server, not as `file://` (a page from disk sends `Origin: null` and is rejected). For example:

```sh
python3 -m http.server 5500
# or
npx serve .
```

3. Open `http://localhost:5500/boeking.html`.
4. Turn "Allow localhost" off again before the site goes live.

A call from the command line (without `Origin`) works too, handy for inspecting responses:

```sh
curl -H "Authorization: Bearer cal_pk_live_YOUR_KEY" https://www.callyndar.com/api/v1/venue
```

## A test venue

Don't book on a customer's real calendar while you build. Ask the owner to create a test venue (a second venue in the same account, with the same services) and create a separate key for it. Every test booking gets the normal confirmation email, so use your own email address.

You cancel test bookings on a real venue through the `manage_url` from the response.

## During the setup phase

If you create a client as a partner, that venue stays in the **setup phase** until the owner activates it (or, with a regular invitation, until the owner agrees). In that phase you can already create a key and build your site:

- **Reading works**: `GET /venue`, `/services`, `/providers`, `/calendar`, `/availability` and `/deposit-policy` respond normally, with the data you enter in the dashboard.
- **Writing is blocked**: `POST /holds`, `DELETE /holds/{id}`, `POST /holds/{id}/deposit`, `POST /bookings` and `POST /bookings/recover` return `403 not_enabled` with `details.reason = "venue_in_setup"`. So no bookings end up in the calendar of a venue that is not live yet.

```sh
curl -H "Authorization: Bearer cal_pk_live_YOUR_KEY" https://www.callyndar.com/api/v1/venue          # 200
curl -X POST -H "Authorization: Bearer cal_pk_live_YOUR_KEY" -H "Content-Type: application/json" \
  -d '{}' https://www.callyndar.com/api/v1/holds                                            # 403 venue_in_setup
```

On `venue_in_setup`, show a calm message on your site ("Online booking is coming soon"). As soon as the owner activates the venue, holds and bookings work with the same key, without changing anything. From then on the usual plan rule applies too (Starter or higher, see [Getting started](/developers/en/getting-started)).

You test the full booking path (hold, deposit, booking) after activation, or on a test venue as above.

## Turnstile

You test your own captcha or Turnstile like any other form on your site.

If Callyndar's optional Turnstile is on for the key (`turnstile_required: true`), always use the `turnstile_site_key` from `GET /venue`. It matches the secret key on Callyndar's side.

- In production that is Callyndar's real site key. Your site's domain must be added to that Turnstile widget (ask Callyndar), otherwise Turnstile shows an error.
- On a local or test installation of Callyndar, `/venue` returns Cloudflare's test site key `1x00000000000000000000AA`, which always passes. It only works together with the test secret of such an installation; in production a token from the test site key is rejected (`turnstile_failed`).

## Stripe

You test deposits on a venue whose Stripe account is in **test mode**. Test card `4242 4242 4242 4242`, a future expiry date and any CVC. More cards are listed under [Deposits](/developers/en/deposits).

## Go-live checklist

- [ ] The real venue's key is in the site, domain(s) are on the key, localhost is off.
- [ ] The form is protected against bots (own captcha or Turnstile). If you use Callyndar's Turnstile: domain added to Callyndar's Turnstile widget.
- [ ] Privacy and terms links are next to the booking button.
- [ ] A real test booking was made and cancelled through the `manage_url`.
- [ ] Error messages tested: time gone (`slot_unavailable`), hold expired (and Turnstile failed, if the key asks for it).
- [ ] The venue has been activated by the owner (no more `venue_in_setup` on `POST /holds`).
- [ ] No guest details in `localStorage`, no other secrets in the HTML.
