# Set up your development environment

Get familiar with the Stripe CLI and our server-side SDKs.

Check out our [no-code docs](https://docs.stripe.com/no-code.md), use a [prebuilt solution](https://stripe.com/partners/directory) from our partner directory, or hire a [Stripe-certified expert](https://stripe.com/partners/directory?t=Consulting).

Stripe’s server-side SDKs and command-line interface (CLI) allow you to interact with Stripe’s REST APIs. Start with the Stripe CLI to streamline your development environment and make API calls.

Use the SDKs to avoid writing boilerplate code. To start sending requests from your environment, choose a language to follow a quickstart guide.

> #### Chrome extensions
> 
> We recommend you build your payment integration with Stripe (such as [Elements](https://docs.stripe.com/payments/elements.md) or [Checkout](https://docs.stripe.com/payments/checkout.md)) on your own website. Then, set up your Chrome extension to send users to this payment page when they’re ready to complete a purchase.
> 
> This method is more secure and easier to maintain than trying to handle payments directly within the extension.

# .NET


In this quickstart, you install the [Stripe CLI](https://docs.stripe.com/cli.md), a tool that gets you command line access to your Stripe integration. You also install the [Stripe .NET server-side SDK](https://github.com/stripe/stripe-dotnet) to get access to Stripe APIs from applications written in C#.

## What you learn

In this quickstart, you’ll learn:

- How to call Stripe APIs without writing a line of code
- How to manage third-party dependencies using the .NET Core CLI, NuGet CLI or the Package Manager Console
- How to install the latest Stripe .NET SDK v52.2.0
- How to send your first SDK request

## Set up the Stripe CLI

### Install and connect

Install the Stripe CLI with [npm](https://www.npmjs.com/):

```bash
npm install --global @stripe/cli
```

> For more installation options for Windows, macOS, Linux, and Docker, check the [Stripe CLI readme](https://github.com/stripe/stripe-cli#installation) on GitHub.

After installation, connect the CLI to your Stripe account by logging in:

```bash
stripe login
```

The CLI displays a pairing code and opens the Stripe Dashboard, where you approve access to accounts, sandboxes, and live mode. The CLI stores your credentials in your operating system’s secure credential store (when available) and refreshes the session automatically. To authenticate with an API key instead, run `stripe login --interactive`, use `stripe config`, pass `--api-key`, or set the `STRIPE_API_KEY` environment variable.

### Confirm setup

Now that you’ve installed the CLI, you can make a single API request to [Create a product](https://docs.stripe.com/api/products/create.md).

#### bash

```bash
stripe products create \
--name="My First Product" \
--description="Created with the Stripe CLI"
```

Look for the product identifier (in `id`) in the response object. Save it for the next step.

If everything worked, the command-line displays the following response.

#### bash

```json
{
  "id": "prod_LTenIrmp8Q67sa", // The identifier looks like this.
  "object": "product",
  "active": true,
  "attributes": [],
  "created": 1668198126,
  "default_price": null,
  "description": "Created with the Stripe CLI",
  "identifiers": {},
  "images": [],
  "livemode": false,
  "metadata": {},
  "name": "My First Product",
  "package_dimensions": null,
  "price": null,
  "product_class": null,
  "shippable": null,
  "sku": "my-first-product-10",
  "statement_descriptor": null,
  "tax_code": null,
  "type": "service",
  "unit_label": null,
  "updated": 1668198126,
  "url": null
}
```

Next, call [Create a price](https://docs.stripe.com/api/prices/create.md) to attach a price of 30 USD. Swap the placeholder in `product` with your product identifier (for example, `prod_LTenIrmp8Q67sa`).

#### bash

```bash
stripe prices create \
  --unit-amount=3000 \
  --currency=usd \
  --product="{{PRODUCT_ID}}"
```

If everything worked, the command-line displays the following response.

#### bash

```json
{
  "id": "price_1KzlAMJJDeE9fu01WMJJr79o", // The identifier looks like this.
  "object": "price",
  "active": true,
  "billing_scheme": "per_unit",
  "created": 1652636348,
  "currency": "usd",
  "livemode": false,
  "lookup_key": null,
  "metadata": {},
  "nickname": null,
  "product": "prod_Lh9iTGZhb2mcBy",
  "recurring": null,
  "tax_behavior": "unspecified",
  "tiers_mode": null,
  "transform_quantity": null,
  "type": "one_time",
  "unit_amount": 3000,
  "unit_amount_decimal": "3000"
}
```

## Install the .NET server-side SDK

The latest version of the Stripe .NET server-side SDK is v52.2.0. It supports .NET Standard 2.0+, .NET Core 2.0+, and .NET Framework 4.6.1+.

Check your [.NET SDK](https://docs.microsoft.com/en-us/dotnet/core/install/how-to-detect-installed-versions) version:

```bash
dotnet --list-sdks
```

### Install the library

Use the [.NET Core Command Line Interface (CLI)](https://docs.microsoft.com/en-us/dotnet/core/tools/) to create a new project from the command line:

```bash
dotnet new console
```

To install the library, run this command to add the package reference to your project file (`.csproj`):

```bash
dotnet add package Stripe.net
```

After you install the library with the CLI, the library is automatically added as a dependency in your project file (`.csproj`). For example:

```xml
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Stripe.net" Version="52.2.0" />
  </ItemGroup>

</Project>
```

### Installation alternatives

**NuGet Command Line Interface (CLI)**—You can use the [NuGet CLI](https://docs.microsoft.com/en-us/nuget/tools/nuget-exe-cli-reference) to install the library:

```bash
nuget install Stripe.net
```

**Package Manager Console (PowerShell)**—If you’re using the [Package Manager Console (PowerShell)](https://docs.microsoft.com/en-us/nuget/tools/package-manager-console), run the following command to install the library:

```PowerShell
Install-Package Stripe.net
```

**VisualStudio**—To add the Stripe.net package to Visual Studio: Open the Solution Explorer. Right-click your project. Click **Manage NuGet Packages**. Click the **Browse** tab and search for **Stripe.net**. Click the **Stripe.net** package, select the appropriate version in the tab and click **Install**.

## Run your first SDK request

Now that you have the .NET SDK installed, you can create a subscription [Product](https://docs.stripe.com/api/products/create.md) and attach a [Price](https://docs.stripe.com/api/prices/create.md) with a couple API requests. We’re using the product identifier returned in the response to create the price in this example.

> #### Use best practices for API keys
> 
> This sample uses the default keys of your Stripe user [account](https://docs.stripe.com/get-started/account/set-up.md) for 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. Only you can see these values. Follow [best practices](https://docs.stripe.com/keys-best-practices.md) to manage your keys safely.

#### Create a product and price

```dotnet
using System;
using Stripe;

class Program
{
  static void Main(string[] args)
  {
    // Don't embed any keys in production code. This is an example.
    // See https://docs.stripe.com/keys-best-practices.
    var client = new StripeClient("sk_test_BQokikJOvBiI2HlWgH4olfQ2");

    var optionsProduct = new ProductCreateOptions
    {
      Name = "Starter Subscription",
      Description = "$12/Month subscription",
    };
    Product product = client.V1.Products.Create(optionsProduct);
    Console.Write("Success! Here is your starter subscription product id: {0}\n", product.Id);

    var optionsPrice = new PriceCreateOptions
    {
      UnitAmount = 1200,
      Currency = "usd",
      Recurring = new PriceRecurringOptions
      {
          Interval = "month",
      },
      Product = product.Id
    };
    Price price = client.V1.Prices.Create(optionsPrice);
    Console.Write("Success! Here is your starter subscription price id: {0}\n", price.Id);
  }
}
```

Save the code to the `Program.cs` file in your project. From the command line, `cd` to the directory containing the file you just saved and run:

#### Program.cs

```bash
dotnet run
```

If everything worked, the command line shows the following response. Save these identifiers so you can use them while building your integration.

#### bash

```bash
Success! Here is your starter subscription product id: prod_0KxBDl589O8KAxCG1alJgiA6
Success! Here is your starter subscription price id: price_0KxBDm589O8KAxCGMgG7scjb
```

## See also

This wraps up the quickstart. See the links below for a few different ways to process a payment for the product you just created.

- [Create a payment link](https://docs.stripe.com/payment-links.md)
- [Stripe-hosted page](https://docs.stripe.com/checkout/quickstart.md)
- [Advanced integration](https://docs.stripe.com/payments/quickstart.md)

