# Testing Issuing 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* environment. This allows you to test your integration before you go live 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 [authorization endpoint](https://docs.stripe.com/issuing/purchases/authorizations.md), make sure that you have set the test endpoint in your [Issuing settings](https://dashboard.stripe.com/account/issuing). You can view test data by switching into your *sandbox* 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. ### 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* 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). # Without code > This is a Without code for when testing-method is without-code. View the original doc at https://docs.stripe.com/issuing/testing?testing-method=without-code. You can simulate a card purchase by specifying authorization details in the Dashboard. ## Create a card Use the [API](https://docs.stripe.com/api/issuing/cards.md) or the [Dashboard](https://dashboard.stripe.com/issuing/cards) to create a test cardholder and card. Visit [Create virtual cards](https://docs.stripe.com/issuing/cards/virtual/issue-cards.md) or [Create physical cards](https://docs.stripe.com/issuing/cards/physical/issue-cards.md) for Dashboard-specific instructions. ## Create a test purchase Navigate to the [Issuing Cards page](https://dashboard.stripe.com/issuing/cards) in your *sandbox* environment, find your newly-created card, then click **Create test purchase**. ![Issuing card details menu with 'Create test purchase' option](images/issuing/card-details-menu.png) You can select to create either an [Authorization](https://docs.stripe.com/api/issuing/authorizations/object.md) or [Transaction](https://docs.stripe.com/api/issuing/transactions/object.md) by force capture. ![Create test purchase sidebar form](images/issuing/create-test-purchase.png) Depending on your selection, you can provide a number of properties, such as amount, business data, and so on. Click **Submit** to create the purchase. If you selected authorization and have configured your [synchronous webhook](https://docs.stripe.com/issuing/controls/real-time-authorizations.md), you can use it to approve or decline the authorization. The browser redirects to the page for the newly-created authorization. ## Create a capture To create a test capture with an authorization in the Dashboard, switch to your *sandbox* environment and complete the following steps: 1. Navigate to the [Authorizations](https://dashboard.stripe.com/issuing/authorizations) page under **Issued Cards**. 1. Click the authorization you want to capture, then click **Capture**. ![Issuing authorization details](images/issuing/issuing-authorization-details.png) You can capture an authorization for an amount that’s lesser, greater, or equivalent to the authorized total. You can also [capture multiple times](https://docs.stripe.com/issuing/purchases/transactions.md?issuing-capture-type=multi_capture) regardless of the authorization’s current state. ![Capture Issuing authorization form](images/issuing/capture-authorization.png) Enter the amount you want to capture, then click **Submit** to create the capture. The browser redirects you to the Transactions page and selects the newly created transaction. # With code > This is a With code for when testing-method is with-code. View the original doc at https://docs.stripe.com/issuing/testing?testing-method=with-code. ## Create a card [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. ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Issuing.CardholderCreateOptions { Name = "Jenny Rosen", Email = "jenny.rosen@example.com", PhoneNumber = "+18008675309", Status = "active", Type = "individual", Individual = new Stripe.Issuing.CardholderIndividualOptions { FirstName = "Jenny", LastName = "Rosen", Dob = new Stripe.Issuing.CardholderIndividualDobOptions { Day = 1, Month = 11, Year = 1981, }, }, Billing = new Stripe.Issuing.CardholderBillingOptions { Address = new AddressOptions { Line1 = "123 Main Street", City = "San Francisco", State = "CA", PostalCode = "94111", Country = "US", }, }, }; var service = new Stripe.Issuing.CardholderService(); Stripe.Issuing.Cardholder cardholder = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.IssuingCardholderParams{ Name: stripe.String("Jenny Rosen"), Email: stripe.String("jenny.rosen@example.com"), PhoneNumber: stripe.String("+18008675309"), Status: stripe.String(string(stripe.IssuingCardholderStatusActive)), Type: stripe.String(string(stripe.IssuingCardholderTypeIndividual)), Individual: &stripe.IssuingCardholderIndividualParams{ FirstName: stripe.String("Jenny"), LastName: stripe.String("Rosen"), DOB: &stripe.IssuingCardholderIndividualDOBParams{ Day: stripe.Int64(1), Month: stripe.Int64(11), Year: stripe.Int64(1981), }, }, Billing: &stripe.IssuingCardholderBillingParams{ Address: &stripe.AddressParams{ Line1: stripe.String("123 Main Street"), City: stripe.String("San Francisco"), State: stripe.String("CA"), PostalCode: stripe.String("94111"), Country: stripe.String("US"), }, }, }; result, err := cardholder.New(params); ``` ```java Stripe.apiKey = "<>"; CardholderCreateParams params = CardholderCreateParams.builder() .setName("Jenny Rosen") .setEmail("jenny.rosen@example.com") .setPhoneNumber("+18008675309") .setStatus(CardholderCreateParams.Status.ACTIVE) .setType(CardholderCreateParams.Type.INDIVIDUAL) .setIndividual( CardholderCreateParams.Individual.builder() .setFirstName("Jenny") .setLastName("Rosen") .setDob( CardholderCreateParams.Individual.Dob.builder() .setDay(1L) .setMonth(11L) .setYear(1981L) .build() ) .build() ) .setBilling( CardholderCreateParams.Billing.builder() .setAddress( CardholderCreateParams.Billing.Address.builder() .setLine1("123 Main Street") .setCity("San Francisco") .setState("CA") .setPostalCode("94111") .setCountry("US") .build() ) .build() ) .build(); Cardholder cardholder = Cardholder.create(params); ``` ```node const stripe = require('stripe')('<>'); const cardholder = await stripe.issuing.cardholders.create({ name: 'Jenny Rosen', email: 'jenny.rosen@example.com', phone_number: '+18008675309', status: 'active', type: 'individual', individual: { first_name: 'Jenny', last_name: 'Rosen', dob: { day: 1, month: 11, year: 1981, }, }, billing: { address: { line1: '123 Main Street', city: 'San Francisco', state: 'CA', postal_code: '94111', country: 'US', }, }, }); ``` ```python import stripe stripe.api_key = "<>" cardholder = stripe.issuing.Cardholder.create( name="Jenny Rosen", email="jenny.rosen@example.com", phone_number="+18008675309", status="active", type="individual", individual={ "first_name": "Jenny", "last_name": "Rosen", "dob": {"day": 1, "month": 11, "year": 1981}, }, billing={ "address": { "line1": "123 Main Street", "city": "San Francisco", "state": "CA", "postal_code": "94111", "country": "US", }, }, ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $cardholder = $stripe->issuing->cardholders->create([ 'name' => 'Jenny Rosen', 'email' => 'jenny.rosen@example.com', 'phone_number' => '+18008675309', 'status' => 'active', 'type' => 'individual', 'individual' => [ 'first_name' => 'Jenny', 'last_name' => 'Rosen', 'dob' => [ 'day' => 1, 'month' => 11, 'year' => 1981, ], ], 'billing' => [ 'address' => [ 'line1' => '123 Main Street', 'city' => 'San Francisco', 'state' => 'CA', 'postal_code' => '94111', 'country' => 'US', ], ], ]); ``` ```ruby Stripe.api_key = '<>' cardholder = Stripe::Issuing::Cardholder.create({ name: 'Jenny Rosen', email: 'jenny.rosen@example.com', phone_number: '+18008675309', status: 'active', type: 'individual', individual: { first_name: 'Jenny', last_name: 'Rosen', dob: { day: 1, month: 11, year: 1981, }, }, billing: { address: { line1: '123 Main Street', city: 'San Francisco', state: 'CA', postal_code: '94111', country: 'US', }, }, }) ``` Next, [create a Card](https://docs.stripe.com/api/.md#create_issuing_card) for the cardholder. ```dotnet StripeConfiguration.ApiKey = "<>"; var options = new Stripe.Issuing.CardCreateOptions { Cardholder = "<>", Type = "virtual", Currency = "usd", Status = "active", }; var service = new Stripe.Issuing.CardService(); Stripe.Issuing.Card card = service.Create(options); ``` ```go stripe.Key = "<>" params := &stripe.IssuingCardParams{ Cardholder: stripe.String("<>"), Type: stripe.String(string(stripe.IssuingCardTypeVirtual)), Currency: stripe.String(string(stripe.CurrencyUSD)), Status: stripe.String(string(stripe.IssuingCardStatusActive)), }; result, err := card.New(params); ``` ```java Stripe.apiKey = "<>"; CardCreateParams params = CardCreateParams.builder() .setCardholder("<>") .setType(CardCreateParams.Type.VIRTUAL) .setCurrency("usd") .setStatus(CardCreateParams.Status.ACTIVE) .build(); Card card = Card.create(params); ``` ```node const stripe = require('stripe')('<>'); const card = await stripe.issuing.cards.create({ cardholder: '<>', type: 'virtual', currency: 'usd', status: 'active', }); ``` ```python import stripe stripe.api_key = "<>" card = stripe.issuing.Card.create( cardholder="<>", type="virtual", currency="usd", status="active", ) ``` ```php $stripe = new \Stripe\StripeClient('<>'); $card = $stripe->issuing->cards->create([ 'cardholder' => '<>', 'type' => 'virtual', 'currency' => 'usd', 'status' => 'active', ]); ``` ```ruby Stripe.api_key = '<>' card = Stripe::Issuing::Card.create({ cardholder: '<>', type: 'virtual', currency: 'usd', status: 'active', }) ``` ## Create an authorization An [Authorization](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 authorization in test-mode with the [Authorization test helpers API](https://docs.stripe.com/api/issuing/authorizations/test_mode_create.md). After you configure [real-time authorizations](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 authorization endpoint builder](https://docs.stripe.com/issuing/controls/real-time-authorizations/quickstart.md). ## Capture an authorization After approval, an Authorization is in a `pending` state while it waits for [capture](https://docs.stripe.com/issuing/purchases/transactions.md). You can simulate capture of the authorization with the API. ```dotnet StripeConfiguration.ApiKey = "<>"; var service = new Stripe.TestHelpers.Issuing.AuthorizationService(); Stripe.Issuing.Authorization authorization = service.Capture("<>"); ``` ```go stripe.Key = "<>" params := &stripe.TestHelpersIssuingAuthorizationCaptureParams{}; result, err := authorization.Capture("<>", params); ``` ```java Stripe.apiKey = "<>"; Authorization resource = Authorization.retrieve("<>"); AuthorizationCaptureParams params = AuthorizationCaptureParams.builder().build(); Authorization authorization = resource.getTestHelpers().capture(params); ``` ```node const stripe = require('stripe')('<>'); const authorization = await stripe.testHelpers.issuing.authorizations.capture( '<>' ); ``` ```python import stripe stripe.api_key = "<>" authorization = stripe.issuing.Authorization.TestHelpers.capture("<>") ``` ```php $stripe = new \Stripe\StripeClient('<>'); $authorization = $stripe->testHelpers->issuing->authorizations->capture( '<>', [] ); ``` ```ruby Stripe.api_key = '<>' authorization = Stripe::Issuing::Authorization::TestHelpers.capture('<>') ``` This generates a new [Transaction](https://docs.stripe.com/api.md#issuing_transaction_object) resource and the Authorization status updates to `closed`.