Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.53 KB

File metadata and controls

52 lines (35 loc) · 1.53 KB

Checkout single product

Requirements

How to run

  1. Confirm .env configuration

This sample requires a Price ID in the PRICE environment variable.

Open .env and confirm PRICE is set equal to the ID of a Price from your Stripe account. It should look something like:

PRICE=price_1Hh1ZeCZ6qsJgndJaX9fauRl

Note that price_12345 is a placeholder and the sample will not work with that price ID. You can create a price from the dashboard or with the Stripe CLI.

Enabling Stripe Tax

In the Server.java file you will find the following code commented out

// .setAutomaticTax(SessionCreateParams.AutomaticTax.builder().setEnabled(true).build())

Uncomment this line of code and the sales tax will be automatically calculated during the checkout.

Make sure you previously went through the set up of Stripe Tax: Set up Stripe Tax and you have your products and prices updated with tax behavior and optionally tax codes: Docs - Update your Products and Prices

  1. Build the jar
mvn package
  1. Run the packaged jar
java -cp target/sample-jar-with-dependencies.jar com.stripe.sample.Server
  1. If you're using the html client, go to localhost:4242 to see the demo. For react, visit localhost:3000.