# Test your Issuing integration

Learn how to test your integration and simulate purchases.

Learn more about [testing](https://docs.stripe.com/testing.md) your Stripe integration.

You can issue cards and simulate purchases using your own Stripe integration in a *sandbox* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes) environment. This allows you to test your integration without having to make real purchases. You can only use these cards for testing within your Stripe account and not for external purchases.

> When testing your [authorisation endpoint](https://docs.stripe.com/issuing/purchases/authorizations.md), make sure that you’ve set the test endpoint in your [Issuing settings](https://dashboard.stripe.com/account/issuing). You can view test data by switching into your *sandbox* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes) environment.

## Fund your test Issuing balance

Before you create test transactions, you must add test funds to the Issuing balance on your account. These aren’t real funds, and you can only use them for simulating test purchases.

### Fiat balance users

#### Issuing users in the US

Issuing users in the US use “pull” funding, and use *top-ups* to fund their Issuing balance. You can create test top-ups in the Dashboard, or with the [Top-ups API](https://docs.stripe.com/api/topups/create.md). Learn more about funding Issuing balances for [US users](https://docs.stripe.com/issuing/funding/balance.md?push-pull-preference=pull).

#### Issuing users in the UK and euro area

To top up their balance, Issuing users in the UK and Europe “push” funds using *funding instructions*. You can do this in your *sandbox* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes) environment, which you  access from the Dashboard, or with the [Funding Instructions API](https://docs.stripe.com/api/funding_instructions.md). Learn more about funding Issuing balances for [UK and euro area users](https://docs.stripe.com/issuing/funding/balance.md?push-pull-preference=push).

### Stablecoin balance users

If your cards draw funds from Bridge wallets, Privy wallets or other non-custodial wallets, connect your sandbox to a Bridge sandbox and fund a test wallet. You can simulate a deposit into a Bridge wallet, or get test tokens for a non-custodial wallet on a supported testnet. See [test stablecoin-backed cards](https://docs.stripe.com/issuing/stablecoin-cards/testing.md).

# With code


## Create a card [Server-side]

[Create a cardholder](https://docs.stripe.com/api.md#create_issuing_cardholder) with a name, billing address, and entity type. You can also provide additional information, if necessary.

```curl
curl https://api.stripe.com/v1/issuing/cardholders \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "name=Jenny Rosen" \
  --data-urlencode "email=jenny.rosen@example.com" \
  --data-urlencode "phone_number=+18008675309" \
  -d status=active \
  -d type=individual \
  -d "individual[first_name]=Jenny" \
  -d "individual[last_name]=Rosen" \
  -d "individual[dob][day]=1" \
  -d "individual[dob][month]=11" \
  -d "individual[dob][year]=1981" \
  -d "billing[address][line1]=123 Main Street" \
  -d "billing[address][city]=San Francisco" \
  -d "billing[address][state]=CA" \
  -d "billing[address][postal_code]=94111" \
  -d "billing[address][country]=US"
```

Next, [create a Card](https://docs.stripe.com/api/.md#create_issuing_card) for the cardholder.

```curl
curl https://api.stripe.com/v1/issuing/cards \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "cardholder={{CARDHOLDER_ID}}" \
  -d type=virtual \
  -d currency=usd \
  -d status=active
```

## Create an authorisation [Server-side]

An [Authorisation](https://docs.stripe.com/api.md#issuing_authorization_object) represents a cardholder’s attempt to make a purchase on a card. You can simulate the creation of an authorisation in a sandbox with the [Authorisation test helpers API](https://docs.stripe.com/api/issuing/authorizations/test_mode_create.md).

```curl
curl https://api.stripe.com/v1/test_helpers/issuing/authorizations \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d "card={{CARD_ID}}" \
  -d amount=1000 \
  -d authorization_method=chip \
  -d "merchant_data[category]=taxicabs_limousines" \
  -d "merchant_data[city]=San Francisco" \
  -d "merchant_data[country]=US" \
  -d "merchant_data[name]=Rocket Rides" \
  -d "merchant_data[network_id]=1234567890" \
  -d "merchant_data[postal_code]=94107" \
  -d "merchant_data[state]=CA"
```

After you configure [real-time authorisations](https://docs.stripe.com/issuing/controls/real-time-authorizations.md), Stripe sends the `issuing_authorization.request` webhook event. You can respond to this event directly to approve or decline it. Learn more about the [real-time authorisation endpoint builder](https://docs.stripe.com/issuing/controls/real-time-authorizations/quickstart.md).

## Capture an authorisation [Server-side]

After approval, an Authorisation is in a `pending` state while it waits for [capture](https://docs.stripe.com/issuing/purchases/transactions.md). You can simulate capture of the authorisation with the API.

```curl
curl -X POST https://api.stripe.com/v1/test_helpers/issuing/authorizations/{{AUTHORIZATION_ID}}/capture \
  -u "<<YOUR_SECRET_KEY>>:"
```

This generates a new [Transaction](https://docs.stripe.com/api.md#issuing_transaction_object) resource and the authorisation status updates to `closed`.

