### Installing Dependencies and Starting the Server (Shell) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md These commands are used to install the project's Node.js dependencies and then start the local development server. This is the initial setup required to run the Stripe Checkout sample application. ```sh npm install npm start ``` -------------------------------- ### Starting the Node.js Application Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/node/README.md This command initiates the Node.js application, typically by executing the script defined as the 'start' command in the project's `package.json`, making the server accessible. ```Shell npm start ``` -------------------------------- ### Installing Node.js Dependencies Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/node/README.md This command installs all necessary Node.js packages and project dependencies defined in the `package.json` file, preparing the application for execution. ```Shell npm install ``` -------------------------------- ### Cloning Stripe Sample using CLI Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This command uses the Stripe CLI to clone the `checkout-single-subscription` sample, guiding the user through server/client language selection and `.env` configuration. It requires the Stripe CLI to be installed and configured. ```sh ./stripe samples create checkout-single-subscription ``` -------------------------------- ### Running Go Server Application Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/go/README.md This shell command executes the main Go server application. It compiles and runs the `server.go` file, starting the web server which will then be accessible via the specified domain, typically `localhost:4242`. ```Shell go run server.go ``` -------------------------------- ### Starting Local PHP Development Server Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/php/README.md This command navigates into the `public` directory and starts a built-in PHP development server on `localhost:4242`, making the application accessible via a web browser. ```Bash cd public php -S localhost:4242 ``` -------------------------------- ### Installing Python Project Dependencies Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/python/README.md This shell command installs all necessary Python packages listed in the `requirements.txt` file into the currently active virtual environment. It ensures all required libraries for the project are available and correctly installed. ```Shell pip install -r requirements.txt ``` -------------------------------- ### Copying Environment Configuration File (Bash) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/php/README.md This command copies the example environment file to the active `.env` file within the server directory. Users must then replace placeholder values with their actual Stripe API keys and define basic and pro price IDs. ```Bash cp .env.example server/php/.env ``` -------------------------------- ### Running Packaged Java Application Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/java/README.md This command executes the compiled Java application from its JAR file using the Java Virtual Machine. It specifies the classpath to include the packaged JAR and then invokes the main class `com.stripe.sample.Server` to start the server. ```Shell java -cp target/sample-jar-with-dependencies.jar com.stripe.sample.Server ``` -------------------------------- ### Copying .env Example File for Node Server Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This command copies the `.env.example` file to `.env` within the `server/node` directory, preparing the environment for local configuration of API keys. This step is crucial for setting up the server's environment variables. ```sh cp .env.example server/node/.env ``` -------------------------------- ### Installing PHP Dependencies with Composer Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/php/README.md This command installs all required PHP dependencies for the project using Composer, ensuring that the application has access to necessary libraries like the Stripe PHP client. ```Bash composer install ``` -------------------------------- ### Installing Ruby Dependencies (Shell) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/ruby/README.md This shell command installs all necessary Ruby gem dependencies for the project, as specified in the `Gemfile`. It is a prerequisite for running the Sinatra application. ```shell bundle install ``` -------------------------------- ### Running the Sinatra Application (Shell) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/ruby/README.md This shell command starts the Sinatra web application by executing the `server.rb` file. Once the application is running, it will be accessible in a web browser at `localhost:4242`. ```shell ruby server.rb ``` -------------------------------- ### Running the .NET Application - Shell Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/dotnet/README.md This shell command is used to compile and run the .NET application. Executing 'dotnet run' from the project's root directory will start the server, making the application accessible. ```sh dotnet run ``` -------------------------------- ### Installing Go Module Dependencies Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/go/README.md These shell commands are used to manage Go module dependencies. `go mod tidy` cleans up unused dependencies and adds missing ones, while `go mod vendor` copies all necessary dependencies into a local `vendor` directory, ensuring reproducible builds. ```Shell go mod tidy go mod vendor ``` -------------------------------- ### Running Flask Application (macOS/Unix) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/python/README.md These shell commands first set the `FLASK_APP` environment variable to `server.py` and then start the Flask development server on port 4242. This makes the web application accessible locally for testing and development purposes. ```Shell export FLASK_APP=server.py python3 -m flask run --port=4242 ``` -------------------------------- ### Creating and Activating Python Virtual Environment (Windows PowerShell) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/python/README.md These PowerShell commands create a new Python virtual environment named 'env' and subsequently activate it. This isolates project dependencies, preventing conflicts with other Python projects or system installations on Windows. ```Shell python3 -m venv env .\env\Scripts\activate.bat ``` -------------------------------- ### Creating and Activating Python Virtual Environment (macOS/Unix) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/python/README.md These shell commands create a new isolated Python virtual environment named 'env' and then activate it. This practice ensures project-specific dependencies do not conflict with system-wide Python installations, promoting a clean development environment. ```Shell python3 -m venv env source env/bin/activate ``` -------------------------------- ### Running a Local Webhook with Stripe CLI (Shell) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This command utilizes the Stripe CLI to forward incoming webhook events from Stripe to a specified local endpoint. This is essential for testing webhook handlers during local development and requires the Stripe CLI to be installed and linked to your Stripe account. ```sh ./stripe listen --forward-to "localhost:4242/webhook" ``` -------------------------------- ### Example Stripe Product ID JSON Response Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This JSON snippet illustrates the structure of a Stripe product object response, specifically highlighting the `id` field which is crucial for creating prices. The `id` value is a unique identifier for the created product. ```json { "id": "prod_RANDOM_ID_VALUE" } ``` -------------------------------- ### Enabling Automatic Tax Calculation in Stripe Checkout (PHP) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/php/README.md This snippet shows how to enable automatic tax calculation for a Stripe Checkout session by uncommenting a specific line in the `create-checkout-session.php` file. It requires prior setup of Stripe Tax and updated product/price configurations. ```PHP // 'automatic_tax' => ['enabled' => true], ``` -------------------------------- ### Enabling Automatic Tax Calculation in Stripe Checkout (JavaScript) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/node/README.md This JavaScript code snippet, located in the `server.js` file, enables automatic tax calculation for Stripe Checkout sessions when uncommented. It requires prior setup of Stripe Tax and updated product/price configurations. ```JavaScript // automatic_tax: { enabled: true } ``` -------------------------------- ### Enabling Automatic Tax in Stripe Checkout Session (Java) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/java/README.md This Java code snippet, found in `Server.java`, demonstrates how to enable automatic tax calculation for a Stripe Checkout Session. Uncommenting this line activates Stripe Tax, provided the necessary setup (product tax behavior, tax codes) has been completed in the Stripe dashboard. ```Java // .setAutomaticTax(SessionCreateParams.AutomaticTax.builder().setEnabled(true).build()) ``` -------------------------------- ### Enabling Automatic Tax in Stripe Checkout (Ruby) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/ruby/README.md This Ruby snippet, found in the `server.rb` file, enables automatic tax calculation for Stripe Checkout sessions. Uncommenting this line activates Stripe Tax, which requires prior setup of Stripe Tax and updated product/price tax behaviors in your Stripe dashboard. ```ruby # automatic_tax: { enabled: true }, ``` -------------------------------- ### Creating Basic Product using Stripe CLI Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This Stripe CLI command creates a new product named 'Basic' with a description 'Basic plan', which is a prerequisite for defining subscription prices. The output will include a product ID necessary for creating associated prices. ```sh ./stripe products create --name="Basic" --description="Basic plan" ``` -------------------------------- ### Creating Premium Product using Stripe CLI Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This Stripe CLI command creates a new product named 'Premium' with a description 'Premium plan', necessary for setting up different subscription tiers. Similar to the basic product, its ID will be needed for price creation. ```sh ./stripe products create --name="Premium" --description="Premium plan" ``` -------------------------------- ### Building Java Project with Maven Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/java/README.md This command uses Maven to compile the Java project and package it into a JAR file. It's a standard step to prepare the application for execution, resolving dependencies and creating the distributable artifact. ```Shell mvn package ``` -------------------------------- ### Navigating to Node.js Server Directory Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This command changes the current directory to the `server/node` folder, which is the first step to run the Node.js implementation of the sample application. Users should execute this command from the root of the cloned repository. ```sh cd server/node ``` -------------------------------- ### Manually Cloning Stripe Sample Repository Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This command manually clones the `checkout-single-subscription` sample repository from GitHub, providing an alternative to using the Stripe CLI. It fetches the entire repository to the local machine. ```sh git clone https://github.com/stripe-samples/checkout-single-subscription ``` -------------------------------- ### Configuring Stripe API Keys in .env Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This snippet shows the format for setting Stripe publishable and secret API keys in the `.env` file, which are essential for authenticating requests to the Stripe API. Users must replace the placeholder values with their actual keys obtained from the Stripe developer dashboard. ```sh STRIPE_PUBLISHABLE_KEY= STRIPE_SECRET_KEY= ``` -------------------------------- ### Creating Product with Tax Code using Stripe CLI Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This Stripe CLI command creates a product named 'Premium' with a specific tax code (`txcd_10000000`) for 'General - Electronically Supplied Services', enabling Stripe Tax calculation. This is used when Stripe Tax is enabled and requires product categorization. ```sh ./stripe products create \n -d "name=Premium" \n -d "description=Premium plan" \n -d "tax_code=txcd_10000000" ``` -------------------------------- ### Configuring Environment Variables for Stripe Go Application Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/go/README.md This YAML configuration defines essential environment variables for a Stripe Go application. It includes Stripe API keys (publishable, secret, webhook secret), the application domain, and price IDs for basic and pro subscriptions, along with the static directory path for the front-end. ```YAML # Stripe API keys - see https://stripe.com/docs/development/quickstart#api-keys STRIPE_PUBLISHABLE_KEY=pk_test... STRIPE_SECRET_KEY=sk_test... # Required to verify signatures in the webhook handler. # See README on how to use the Stripe CLI to test webhooks STRIPE_WEBHOOK_SECRET=whsec_... DOMAIN=http://localhost:4242 # Price ID for a recurring price BASIC_PRICE_ID=price_xyz987... # Price ID for a second recurring price PRO_PRICE_ID=price_abc123... # Path to front-end implementation. Note: PHP has it's own front end implementation. STATIC_DIR=../../client/html ``` -------------------------------- ### Running Flask Application (Windows PowerShell) Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/python/README.md These PowerShell commands set the `FLASK_APP` environment variable to `server.py` and then initiate the Flask development server on port 4242. This allows the web application to be accessed and tested locally on Windows systems. ```Shell $env:FLASK_APP="server.py" python3 -m flask run --port=4242 ``` -------------------------------- ### Configuring Environment Variables for Stripe API - YAML Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/dotnet/README.md This YAML snippet demonstrates the required environment variables for the Stripe Checkout application. It includes API keys for authentication, a webhook secret for signature verification, and paths for the static front-end directory and application domain. ```yaml # Stripe API keys - see https://stripe.com/docs/development/quickstart#api-keys STRIPE_PUBLISHABLE_KEY=pk_test... STRIPE_SECRET_KEY=sk_test... # Required to verify signatures in the webhook handler. # See README on how to use the Stripe CLI to test webhooks STRIPE_WEBHOOK_SECRET=whsec_... # Path to front-end implementation. Note: PHP has it's own front end implementation. STATIC_DIR=../../client/html DOMAIN=http://localhost:4242 ``` -------------------------------- ### Creating Monthly Price for Basic Product using Stripe CLI Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This Stripe CLI command creates a monthly recurring price of $18.00 (1800 cents) for the specified basic product, essential for subscription checkout. The `ID_OF_BASIC_PRODUCT` placeholder must be replaced with the actual product ID obtained from the previous step. ```sh ./stripe prices create \n -d "product=ID_OF_BASIC_PRODUCT" \n -d "unit_amount=1800" \n -d "currency=usd" \n -d "recurring[interval]=month" ``` -------------------------------- ### Creating Monthly Price for Premium Product using Stripe CLI Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This Stripe CLI command creates a monthly recurring price of $18.00 (1800 cents) for the specified premium product, enabling different subscription options. The `ID_OF_PREMIUM_PRODUCT` placeholder must be replaced with the actual product ID. ```sh ./stripe prices create \n -d "product=ID_OF_PREMIUM_PRODUCT" \n -d "unit_amount=1800" \n -d "currency=usd" \n -d "recurring[interval]=month" ``` -------------------------------- ### Enabling Stripe Tax in Go Checkout Session Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/go/README.md This Go code snippet, found in `server.go`, enables automatic tax calculation for a Stripe Checkout Session. Uncommenting this line integrates Stripe Tax, provided that Stripe Tax is set up and products/prices have appropriate tax behaviors and codes. ```Go // AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{Enabled: stripe.Bool(true)}, ``` -------------------------------- ### Creating Price with Exclusive Tax Behavior using Stripe CLI Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/README.md This Stripe CLI command creates a monthly recurring price of $18.00 with `exclusive` tax behavior for a specified product, allowing Stripe Tax to be added on top of the price. The `product` parameter requires the ID of a previously created product. ```sh ./stripe prices create \n -d "unit_amount=1800" \n -d "currency=usd" \n -d "tax_behavior=exclusive" \n -d "recurring[interval]=month" \n -d "product=" ``` -------------------------------- ### Enabling Automatic Tax Calculation in Stripe Checkout Session - C# Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/dotnet/README.md This C# code snippet shows how to enable automatic tax calculation within a Stripe Checkout Session. Uncommenting this line in 'Controllers/PaymentsController.cs' will activate Stripe Tax, provided that Stripe Tax is already set up and products/prices are configured with tax behavior. ```csharp // AutomaticTax = new SessionAutomaticTaxOptions { Enabled = true }, ``` -------------------------------- ### Enabling Stripe Tax in Python Flask for Checkout Source: https://github.com/stripe-samples/checkout-single-subscription/blob/main/server/python/README.md This Python snippet, found in `server.py`, enables automatic tax calculation for Stripe Checkout sessions by uncommenting a specific line. Prerequisites include setting up Stripe Tax in the Stripe Dashboard and ensuring products/prices are updated with tax behavior and tax codes. ```Python # automatic_tax={'enabled': True}, ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.