Skip to content
Create account or Sign in
The Stripe Docs logo
/
Ask AI
Create accountSign in
Get started
Payments
Revenue
Platforms and marketplaces
Money management
Developer resources
APIs & SDKsHelp
OverviewSee all products
About the APIs
Start building
Create an account
Quickstarts
Start developing
    Set up your development environment
    Send your first API request
    Build and test new features
    Go-live checklist
    Release phases
Build with an LLM
Use Stripe without code
Migrate to Stripe
Common use cases
OverviewAccept simple payments as a startupSell subscriptions as a Saas startupBuild a subscriptions solution with usage-based pricingAccept payments in personSend invoices to collect payments
United States
English (United States)
HomeGet startedStart developing

Set up your development environment

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

Not a developer?

Check out our no-code docs, use a prebuilt solution from our partner directory, or hire a Stripe-certified expert.

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 or Checkout) 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.

In this quickstart, you install the Stripe CLI—an essential tool that gets you command line access to your Stripe integration. You also install the Stripe Java server-side SDK to get access to Stripe APIs from applications written in Java.

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 Maven or Gradle
  • How to install the latest Stripe Java SDK v30.0.0
  • How to send your first SDK request

Initial setup

First, create a Stripe account or sign in.

Set up the Stripe CLI

Install

From the command-line, use an install script or download and extract a versioned archive file for your operating system to install the CLI.

To install the Stripe CLI with homebrew, run:

Command Line
brew install stripe/stripe-cli/stripe

This command fails if you run it on the Linux version of homebrew, but you can use this alternative or follow the instructions on the Linux tab.

Command Line
brew install stripe-cli

Authenticate

Log in and authenticate your Stripe user account to generate a set of restricted keys. To learn more, see Stripe CLI keys and permissions.

Command Line
stripe login

Press the Enter key on your keyboard to complete the authentication process in your browser.

Output
Your pairing code is: enjoy-enough-outwit-win This pairing code verifies your authentication with Stripe. Press Enter to open the browser or visit https://dashboard.stripe.com/stripecli/confirm_auth?t=THQdJfL3x12udFkNorJL8OF1iFlN8Az1 (^C to quit)

Confirm setup

Now that you’ve installed the CLI, you can make a single API request to Create a product.

Command Line
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.

{ "id":
"prod_LTenIrmp8Q67sa"
, "object": "product",

Next, call Create a price to attach a price of 30 USD. Swap the placeholder in product with your product identifier (for example, prod_LTenIrmp8Q67sa).

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

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

{ "id":
"price_1KzlAMJJDeE9fu01WMJJr79o"
, "object": "price",

Manage third-party dependencies

We recommend managing third-party dependencies using Maven or Gradle, which help you add new libraries and include them in your Java projects.

Initialize a project

  • To create a project with Maven, see How do I make my first Maven project?.
  • To create a project with Gradle, see Building Java Applications Sample.

Install the Java server-side SDK

The latest version of the Stripe Java server-side SDK is v30.0.0. It supports Java versions 1.8+.

Check your Java version:

Command Line
java -version

Install the library

  • With Maven, place the following in your project’s pom.xml file:
pom.xml
<dependency> <groupId>com.stripe</groupId> <artifactId>stripe-java</artifactId> <version>30.0.0</version> </dependency>
  • With Gradle, paste the next line inside the dependencies block of your build.gradle file:
build.gradle
implementation 'com.stripe:stripe-java:30.0.0'

Installation alternatives

Manual installation—You can manually install stripe-java with the following JARs: Download the Stripe JAR (.jar).

Download the Gson JAR (.jar) for Google Gson.

Proguard—If you’re using ProGuard, be sure to exclude the library by adding the following to your proguard.cfg file:

proguard.cfg
-keep class com.stripe.** { *; }

Run your first SDK request

Now that you have the Java SDK installed, you can create a subscription Product and attach a Price with a couple API requests. We’re using the product identifier returned in the response to create the price in this example.

Note

This sample uses the default keys of your Stripe user account for your sandbox environment. Only you can see these values.

CreatePrice.java
package com.stripe.sample; import com.stripe.Stripe; import com.stripe.exception.StripeException; import com.stripe.model.Product; import com.stripe.param.ProductCreateParams; import com.stripe.param.PriceCreateParams; import com.stripe.model.Price; public class Server { public static void main(String[] args) throws StripeException { Stripe.apiKey = "sk_test_BQokikJOvBiI2HlWgH4olfQ2"; ProductCreateParams productParams = ProductCreateParams.builder() .setName("Starter Subscription") .setDescription("$12/Month subscription") .build(); Product product = Product.create(productParams); System.out.println("Success! Here is your starter subscription product id: " + product.getId()); PriceCreateParams params = PriceCreateParams .builder() .setProduct(product.getId()) .setCurrency("usd") .setUnitAmount(1200L) .setRecurring( PriceCreateParams.Recurring .builder() .setInterval(PriceCreateParams.Recurring.Interval.MONTH) .build()) .build(); Price price = Price.create(params); System.out.println("Success! Here is your starter subscription price id: " + price.getId()); } }

Save the file as CreatePrice.java. From the project in your IDE for Maven or Gradle, run the sample. For example: Run 'CreatePrice.main()'.

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

Command Line
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
  • Prebuilt checkout page
  • Custom payment flow
Was this page helpful?
YesNo
  • Need help? Contact Support.
  • Check out our changelog.
  • Questions? Contact Sales.
  • LLM? Read llms.txt.
  • Powered by Markdoc