Issuing
Testing

Testing

Learn how to test your integration and simulate purchases.

You can issue cards and simulate purchases using your own Stripe integration in test mode. This allows you to test your integration before you go live and issue cards that can be used to make real purchases.

Before you create issuing test mode transactions, fund your Issuing balance with test mode top-ups. You can only use these cards for testing within your Stripe account and not for external purchases.

You can simulate a card purchase by specifying authorization details in the Dashboard.

1 Create a card Dashboard

Use the API or Dashboard to create a cardholder and card in test mode.

2 Create a test authorization Dashboard

In the Dashboard, first make sure you’re viewing test data. Go to the Issuing Cards page, find your newly-created card, and scroll to the “Authorizations” section. Then click Create test authorization.

This modal allows you to specify custom values for the test authorization you want to create.

Click submit to create the the authorization. If your synchronous webhook is configured, it can be used to approve or decline. The browser will redirect to the details page for the newly-created authorization.

The details for your newly-created authorization.

3 Viewing transaction details Dashboard

The authorization is automatically captured, and a corresponding transaction is created. You can view more details on the Transactions page in the Dashboard.

The details for your newly-created transaction.

You can simulate a card purchase using your test API keys with the following process:

  1. Fund your issuing balance
  2. Create a cardholder
  3. Create a card
  4. Retrieve the new card’s details
  5. Create a Source object using the card
  6. Create an uncaptured charge using the source

1 Fund your issuing balance

To fund your issuing balance, create a top-up with the destination_balance set to “issuing”.

2 Create a cardholder Server-side

Create a cardholder with a name, billing address, and entity type. You can also provide additional information, if necessary.

curl https://api.stripe.com/v1/issuing/cardholders \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d name="Jenny Rosen" \ -d email="jenny.rosen@example.com" \ -d phone_number="+18008675309" \ -d status=active \ -d type=individual \ -d "billing[address][line1]"="1234 Main Street" \ -d "billing[address][city]"="San Francisco" \ -d "billing[address][state]"=CA \ -d "billing[address][postal_code]"=94111 \ -d "billing[address][country]"=US
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' cardholder = Stripe::Issuing::Cardholder.create({ name: 'Jenny Rosen', email: 'jenny.rosen@example.com', phone_number: '+18008675309', status: 'active', type: 'individual', billing: { address: { line1: '1234 Main Street', city: 'San Francisco', state: 'CA', postal_code: '94111', country: 'US', }, }, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' cardholder = stripe.issuing.Cardholder.create( name='Jenny Rosen', email='jenny.rosen@example.com', phone_number='+18008675309', status='active', type='individual', billing={ 'address': { 'line1': '1234 Main Street', 'city': 'San Francisco', 'state': 'CA', 'postal_code': '94111', 'country': 'US' } } )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $cardholder = \Stripe\Issuing\Cardholder::create([ 'name' => 'Jenny Rosen', 'email' => 'jenny.rosen@example.com', 'phone_number' => '+18008675309', 'status' => 'active', 'type' => 'individual', 'billing' => [ 'address' => [ 'line1' => '1234 Main Street', 'city' => 'San Francisco', 'state' => 'CA', 'postal_code' => '94111', 'country' => 'US', ], ], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; CardholderCreateParams params = CardholderCreateParams.builder() .setName("Jenny Rosen") .setEmail("jenny.rosen@example.com") .setPhoneNumber("+18008675309") .setStatus(CardholderCreateParams.Status.ACTIVE) .setType(CardholderCreateParams.Type.INDIVIDUAL) .setBilling( CardholderCreateParams.Billing.builder() .setAddress( CardholderCreateParams.Billing.Address.builder() .setLine1("1234 Main Street") .setCity("San Francisco") .setState("CA") .setPostalCode("94111") .setCountry("US") .build()) .build()) .build(); Cardholder cardholder = Cardholder.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const cardholder = await stripe.issuing.cardholders.create({ name: 'Jenny Rosen', email: 'jenny.rosen@example.com', phone_number: '+18008675309', status: 'active', type: 'individual', billing: { address: { line1: '1234 Main Street', city: 'San Francisco', state: 'CA', postal_code: '94111', country: 'US', }, }, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.IssuingCardholderParams{ Billing: &stripe.IssuingBillingParams{ Address: &stripe.AddressParams{ Country: stripe.String("US"), Line1: stripe.String("1234 Main Street"), City: stripe.String("San Francisco"), PostalCode: stripe.String("94111"), State: stripe.String("CA"), }, }, Email: stripe.String("jenny.rosen@example.com"), Name: stripe.String("Jenny Rosen"), PhoneNumber: stripe.String("+18008675309"), Status: stripe.String(string(stripe.IssuingCardholderStatusActive)), Type: stripe.String(string(stripe.IssuingCardholderTypeIndividual)), } ch, err := cardholder.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new CardholderCreateOptions { Billing = new BillingOptions { Address = new AddressOptions { Line1 = "1234 Main Street", City = "San Francisco", State = "CA", PostalCode = "94111", Country = "US", }, }, Email = "jenny.rosen@example.com", PhoneNumber = "+18008675309", Name = "Jenny Rosen", Status = "active", Type = "individual", }; var service = new CardholderService(); var cardholder = service.Create(options);

3 Create a card Server-side

After creating a cardholder, you can create a card for them. Provide the id of the Cardholder object and currency. For immediate testing, create a virtual card and set its status to active.

curl https://api.stripe.com/v1/issuing/cards \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d cardholder=ich_1Cm3pZIyNTgGDVfzI83rasFP \ -d type=virtual \ -d currency=usd \ -d status=active
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' card = Stripe::Issuing::Card.create({ cardholder: 'ich_1Cm3pZIyNTgGDVfzI83rasFP', type: 'virtual', currency: 'usd', status: 'active', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' card = stripe.issuing.Card.create( cardholder='ich_1Cm3pZIyNTgGDVfzI83rasFP', type='virtual', currency='usd', status='active' )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $card = \Stripe\Issuing\Card::create([ 'cardholder' => 'ich_1Cm3pZIyNTgGDVfzI83rasFP', 'type' => 'virtual', 'currency' => 'usd', 'status' => 'active', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; CardCreateParams params = CardCreateParams.builder() .setCardholder("ich_1Cm3pZIyNTgGDVfzI83rasFP") .setType(CardCreateParams.Type.VIRTUAL) .setCurrency("usd") .setStatus(CardCreateParams.Status.ACTIVE) .build(); Card card = Card.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const card = await stripe.issuing.cards.create({ cardholder: 'ich_1Cm3pZIyNTgGDVfzI83rasFP', type: 'virtual', currency: 'usd', status: 'active', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.IssuingCardParams{ Cardholder: stripe.String("ich_1Cm3pZIyNTgGDVfzI83rasFP"), Currency: stripe.String(string(stripe.CurrencyUSD)), Type: stripe.String(string(stripe.IssuingCardTypeVirtual)), Status: stripe.String(string(stripe.IssuingCardStatusInactive)), } c, _ := card.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new CardCreateOptions { Cardholder = "ich_1Cm3pZIyNTgGDVfzI83rasFP", Type = "virtual", Currency = "usd", Status = "active", }; var service = new CardService(); var card = service.Create(options);

4 Retrieve card details Server-side

You can retrieve both the full unredacted card number and CVC from the API. For security reasons, these fields are only available for virtual cards and will be omitted unless you explicitly request them with the expand parameter. Additionally, they are only available via the “Retrieve a card” endpoint.

curl https://api.stripe.com/v1/issuing/cards/ic_1Cm3paIyNTgGDVfzBqq1uqxR \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d "expand[]"=number \ -d "expand[]"=cvc \ -G
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' card_details = Stripe::Issuing::Card.retrieve({ id: 'ic_1Cm3paIyNTgGDVfzBqq1uqxR', expand: ['number', 'cvc'], })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' card_details = stripe.issuing.Card.retrieve( 'ic_1Cm3paIyNTgGDVfzBqq1uqxR', expand=['number', 'cvc'] )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $card = \Stripe\Issuing\Card::retrieve( 'id' => 'ic_1Cm3paIyNTgGDVfzBqq1uqxR', 'expand' => ['number', 'cvc'], );
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; CardRetrieveParams params = CardRetrieveParams.builder() .addAllExpand(Arrays.asList("number", "cvc")) .build(); Card card = Card.retrieve("ic_1Cm3paIyNTgGDVfzBqq1uqxR", params, null);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); stripe.issuing.cards.retrieve('ic_1CoYuRKEl2ztzE5GIEDjQiUI', { expand: ['number', 'cvc'], });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.CardParams{} params.AddExpand("number") params.AddExpand("cvc") c, err := card.Get("ic_1CoYuRKEl2ztzE5GIEDjQiUI", nil)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var service = new CardService(); var options = new CardGetOptions(); options.AddExpand("number"); options.AddExpand("cvc"); var details = service.Get("ic_1CoYuRKEl2ztzE5GIEDjQiUI", options);

5 Create source Server-side

Using the newly issued card’s details, create a source. A source will allow you to create a test charge as it simulates the swipe or entry of an issued card at the time of purchase. If you provide address details or a CVC, these will be compared to the values that you define when creating the card, and the comparison results will be returned.

curl https://api.stripe.com/v1/sources \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d type=card \ -d "card[number]"=4000009990000006 \ -d "card[exp_month]"=8 \ -d "card[exp_year]"=2022
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' source = Stripe::Source.create({ type: 'card', card: { number: '4000009990000006', exp_month: 8, exp_year: 2022, }, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' source = stripe.Source.create( type='card', card={ 'number': '4000009990000006', 'exp_month': 8, 'exp_year': 2022, }, )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $source = \Stripe\Source::create([ 'type' => 'card', 'card' => [ 'number' => '4000009990000006', 'exp_month' => 8, 'exp_year' => 2022, ], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; SourceCreateParams params = SourceCreateParams.builder() .setType("card") .putExtraParam("card[number]", "4000009990000006") .putExtraParam("card[exp_month]", "8") .putExtraParam("card[exp_year]", "2022") .build(); Source source = Source.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const source = await stripe.sources.create({ type: 'card', card: { number: '4000009990000006', exp_month: 8, exp_year: 2022, }, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.SourceObjectParams{ Type: stripe.String("card"), Currency: stripe.String(string(stripe.CurrencyUSD)), TypeData: map[string]string{ "number": "4000009990000006", "exp_month": "8", "exp_year": "2022", }, } s, _ := source.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new SourceCreateOptions { Type = SourceType.Card, Currency = "usd", Card = new CreditCardOptions { Number = "4000009990000006", ExpMonth = 8, ExpYear = 2022, }, }; var service = new SourceService(); var source = service.Create(options);

6 Create an uncaptured charge Server-side

Using auth and capture, create a charge that is not immediately captured.

curl https://api.stripe.com/v1/charges \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d source=src_1Cn6EvIyNTgGDVfzosvqD8ld \ -d amount=2000 \ -d currency=usd \ -d capture=false
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' charge = Stripe::Charge.create({ source: 'src_1Cn6EvIyNTgGDVfzosvqD8ld', amount: 2000, currency: 'usd', capture: false, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' charge = stripe.Charge.create( source='src_1Cn6EvIyNTgGDVfzosvqD8ld', amount=2000, currency='usd', capture=False, )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $charge = \Stripe\Charge::create([ 'source' => 'src_1Cn6EvIyNTgGDVfzosvqD8ld', 'amount' => 2000, 'currency' => 'usd', 'capture' => false, ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; ChargeCreateParams params = ChargeCreateParams.builder() .setSource("src_1Cn6EvIyNTgGDVfzosvqD8ld") .setAmount(2000L) .setCurrency("usd") .setCapture(false) .build(); Charge charge = Charge.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const charge = await stripe.charges.create({ source: 'src_1Cn6EvIyNTgGDVfzosvqD8ld', amount: 2000, currency: 'usd', capture: false, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.ChargeParams{ Amount: stripe.Int64(2000), Currency: stripe.String(string(stripe.CurrencyUSD)), Capture: stripe.Bool(false), } params.SetSource("src_1Cn6EvIyNTgGDVfzosvqD8ld") c, _ := charge.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new ChargeCreateOptions { Source = "src_1Cn6EvIyNTgGDVfzosvqD8ld", Amount = 2000, Currency = "usd", Capture = false, }; var service = new ChargeService(); var charge = service.Create(options);

This step results in an authorization request. If there are spending controls on the card, they are applied. If your integration is configured to receive and handle authorization requests, Stripe also sends the issuing_authorization.request event to your test authorization endpoint.

You can test international purchases by creating a charge in a currency that’s different from the card’s own currency (e.g., create a gbp charge for a usd card).

Managing purchases with the API

You can test how your integration handles changes to authorizations by replicating the possible actions that can occur.

Capturing an authorization (uncaptured charge)

To settle an uncaptured charge, which results in the creation of a Transaction object, capture the charge.

curl https://api.stripe.com/v1/charges/ch_1CmMk3IyNTgGDVfzqgWGCQr5/capture \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -X POST
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' charge = Stripe::Charge.capture('ch_1CmMk3IyNTgGDVfzqgWGCQr5')
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' charge = stripe.Charge.capture('ch_1CmMk3IyNTgGDVfzqgWGCQr5')
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $charge = \Stripe\Charge::retrieve('ch_1CmMk3IyNTgGDVfzqgWGCQr5'); $charge->capture();
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; Charge charge = Charge.retrieve("ch_1CmMk3IyNTgGDVfzqgWGCQr5"); charge.capture();
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const charge = await stripe.charges.capture('ch_1CmMk3IyNTgGDVfzqgWGCQr5');
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" ch, err := charge.Capture("ch_1CmMk3IyNTgGDVfzqgWGCQr5")
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var service = new ChargeService(); var charge = service.Capture("ch_1CmMk3IyNTgGDVfzqgWGCQr5");

Partial capture

An authorization can be captured for any amount below what has been authorized. You can partially capture a test charge by providing a value for amount when capturing a charge.

Partially capturing a charge creates a Transaction object for the amount captured, and a reversal of the remaining amount. This reversal is represented as an update to the Authorization object.

Reversing an authorization

You can reverse (void) an authorization that has not been captured by creating a refund for the uncaptured charge.

curl https://api.stripe.com/v1/refunds \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d charge=ch_1CmMk3IyNTgGDVfzqgWGCQr5
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' refund = Stripe::Refund.create({ charge: 'ch_1CmMk3IyNTgGDVfzqgWGCQr5', })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' refund = stripe.Refund.create( charge='ch_1CmMk3IyNTgGDVfzqgWGCQr5' )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $refund = \Stripe\Refund::create([ 'charge' => 'ch_1CmMk3IyNTgGDVfzqgWGCQr5', ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; RefundCreateParams params = RefundCreateParams.builder() .setCharge("ch_1CmMk3IyNTgGDVfzqgWGCQr5") .build(); Refund refund = Refund.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const refund = await stripe.refunds.create({ charge: 'ch_1CmMk3IyNTgGDVfzqgWGCQr5', });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.RefundParams{ Charge: stripe.String("ch_1CmMk3IyNTgGDVfzqgWGCQr5"), } ref, err := refund.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new RefundCreateOptions { Charge = "ch_1CmMk3IyNTgGDVfzqgWGCQr5", }; var service = new RefundService(); var refund = service.Create(options);

Refunding a captured charge

Refunding a captured charge uses the same method as refunding an uncaptured one. A Transaction object of type refund is created that references the original authorization.

curl https://api.stripe.com/v1/refunds \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d charge=ch_1CmMk3IyNTgGDVfzqgWGCQr5 \ -d amount=2000
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' refund = Stripe::Refund.create({ charge: 'ch_1CmMk3IyNTgGDVfzqgWGCQr5', amount: 2000, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' refund = stripe.Refund.create( charge='ch_1CmMk3IyNTgGDVfzqgWGCQr5', amount=2000, )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $refund = \Stripe\Refund::create([ 'charge' => 'ch_1CmMk3IyNTgGDVfzqgWGCQr5', 'amount' => 2000, ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; RefundCreateParams params = RefundCreateParams.builder() .setCharge("ch_1CmMk3IyNTgGDVfzqgWGCQr5") .setAmount(2000L) .build(); Refund refund = Refund.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const refund = await stripe.refunds.create({ charge: 'ch_1CmMk3IyNTgGDVfzqgWGCQr5', amount: 2000, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.RefundParams{ Charge: stripe.String("ch_1CmMk3IyNTgGDVfzqgWGCQr5"), Amount: stripe.Int64(2000), } ref, err := refund.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new RefundCreateOptions { Charge = "ch_1CmMk3IyNTgGDVfzqgWGCQr5", Amount = 2000, }; var service = new RefundService(); var refund = service.Create(options);

Testing verification outcomes

Issued cards support AVS and CVC checks. You can simulate authorizations that either provide the wrong information so these checks fail, or no information so the checks cannot be run. The results of these checks are represented on Authorization objects as values for verification_data.

When creating a Source object for an issued card, providing address and CVC information is optional. If they are not provided, the resulting ZIP code, street address, and CVC checks return not_provided. To test AVS and CVC checks, provide an address, a CVC, or both during Source creation.

curl https://api.stripe.com/v1/sources \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d type=card \ -d "card[number]"=4000009990000006 \ -d "card[exp_month]"=8 \ -d "card[exp_year]"=2022 \ -d "card[cvc]"=123 \ -d "owner[address][line1]"="1234 Main Street" \ -d "owner[address][city]"="San Francisco" \ -d "owner[address][state]"=CA \ -d "owner[address][postal_code]"=94111 \ -d "owner[address][country]"=US
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' source = Stripe::Source.create({ card: { number: '4000009990000006', exp_month: 8, exp_year: 2022, cvc: 123, }, type: 'card', owner: { address: { line1: '1234 Main Street', city: 'San Francisco', state: 'CA', postal_code: '94111', country: 'US', }, }, })
# Set your secret key. Remember to switch to your live secret key in production! # See your keys here: https://dashboard.stripe.com/account/apikeys stripe.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc' source = stripe.Source.create( type='card', card={ 'number': '4000009990000006', 'exp_month': 8, 'exp_year': 2022, 'cvc': 123, }, owner={ 'address': { 'line1': '1234 Main Street', 'city': 'San Francisco', 'state': 'CA', 'postal_code': '94111', 'country': 'US', }, }, )
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys \Stripe\Stripe::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); $source = \Stripe\Source::create([ 'type' => 'card', 'card' => [ 'number' => '4000009990000006', 'exp_month' => 8, 'exp_year' => 2022, 'cvc' => 123, ], 'owner' => [ 'address' => [ 'line1' => '1234 Main Street', 'city' => 'San Francisco', 'state' => 'CA', 'postal_code' => '94111', 'country' => 'US', ], ], ]);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys Stripe.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; SourceCreateParams params = SourceCreateParams.builder() .setType("card") .setOwner( SourceCreateParams.Owner.builder() .setAddress( SourceCreateParams.Owner.Address.builder() .setLine1("1234 Main Street") .setCity("San Francisco") .setState("CA") .setPostalCode("94111") .setCountry("US") .build()) .build()) .putExtraParam("card[number]", "4000009990000006") .putExtraParam("card[exp_month]", "8") .putExtraParam("card[exp_year]", "2022") .putExtraParam("card[cvc]", "314") .build(); Source source = Source.create(params);
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys const stripe = require('stripe')('sk_test_4eC39HqLyjWDarjtT1zdp7dc'); const source = await stripe.sources.create({ type: 'card', card: { number: '4000009990000006', exp_month: 8, exp_year: 2022, cvc: 123, }, owner: { address: { line1: '1234 Main Street', city: 'San Francisco', state: 'CA', postal_code: '94111', country: 'US', }, }, });
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys stripe.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc" params := &stripe.SourceParams{ Type: stripe.String("card"), Card: &stripe.CardParams{ Number: stripe.String("4000009990000006"), ExpMonth: stripe.String("8"), ExpYear: stripe.String("2022"), CVC: stripe.String("123"), }, Owner: &stripe.SourceOwnerParams{ Address: &stripe.AddressParams{ Line1: stripe.String("1234 Main Street"), City: stripe.String("San Francisco"), PostalCode: stripe.String("94111"), State: stripe.String("CA"), Country: stripe.String("US"), }, }, } s, _ := source.New(params)
// Set your secret key. Remember to switch to your live secret key in production! // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"; var options = new SourceCreateOptions { Type = "card", Card = new CreditCardOptions { Number = "4000009990000006", ExpMonth = 8, ExpYear = 2022, Cvc = "123", }, Owner = new SourceOwnerOptions { Address = new AddressOptions { Line1 = "1234 Main Street", City = "San Francisco", PostalCode = "94111", State = "CA", Country = "US", }, }, }; var service = new SourceService(); var source = service.Create(options);

Providing the same address as the billing address on the card results in a successful AVS check (the respective verification_data fields return match), as well as providing the correct CVC (the value returned in the card details) for the CVC check.

To test for a failed check, create a source that has a different ZIP code, street address, and CVC—this results in verification_data returning mismatch.

Was this page helpful?
Questions? Contact us.
Developer tutorials on YouTube.
You can unsubscribe at any time. Read our privacy policy.