From 5244cae3b7f0f409b746002d674fb254dee0827f Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Mon, 15 Jul 2019 12:28:50 -0700 Subject: [PATCH] A few fixes to README.md (#29) --- .editorconfig | 4 ++ README.md | 132 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 83 insertions(+), 53 deletions(-) diff --git a/.editorconfig b/.editorconfig index c3bc90e1d..daa0027bf 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,3 +11,7 @@ trim_trailing_whitespace = true [*.go] indent_style = tab indent_size = 4 + +[*.md] +indent_style = space +indent_size = 2 diff --git a/README.md b/README.md index 704c6fd7a..8a30bd5cb 100644 --- a/README.md +++ b/README.md @@ -13,19 +13,17 @@ The main focus for this initial release is to improve the developer while integr ## Table of Contents - * [Stripe CLI](#stripe-cli) - * [Installation](#installation) - * [Download the CLI](#download-the-cli) - * [Commands](#commands) - * [login](#login) - * [listen](#listen) - * [get, post, and delete](#get-post-and-delete) - * [trigger](#trigger) - * [Development](#development) - * [Installing](#installing) - * [Deploying](#deploying) - * [Development](#development-1) - * [Tests](#tests) +* [Stripe CLI](#stripe-cli) + * [Installation](#installation) + * [Download the CLI](#download-the-cli) + * [Commands](#commands) + * [login](#login) + * [listen](#listen) + * [get, post, and delete](#get-post-and-delete) + * [trigger](#trigger) + * [Developing the Stripe CLI](#developing-the-stripe-cli) + * [Installation](#installation-1) + * [Tests](#tests) ## Installation @@ -34,11 +32,15 @@ The main focus for this initial release is to improve the developer while integr > **Note:** For Homebrew, you’ll need to create a personal access token because this repository is still private. Make sure to save your access token since GitHub won’t show it to you again. 1. Create a [personal access token](https://github.com/settings/tokens) on github.com. Provide a name like “Stripe CLI: Homebrew download” and enable repository access. + 2. Copy the token github.com provides and add a line to your terminal configuration, e.g. `~/.bash_profile` or `~/.zshrc`: -``` -export HOMEBREW_GITHUB_API_TOKEN=foobar -``` + + ```sh + export HOMEBREW_GITHUB_API_TOKEN=foobar + ``` + 3. Run `brew tap stripe/stripe-cli` + 4. Run `brew install stripe` 🎉 The `stripe` command should now work! @@ -49,13 +51,17 @@ export HOMEBREW_GITHUB_API_TOKEN=foobar The Stripe CLI runs commands using a global configuration or project-specific configuration. To configure the CLI globally, run: - $ stripe login +```sh +$ stripe login +``` You'll be redirected to the Stripe dashboard to confirm that you want to give access to your account to the CLI. After confirming, a new API key will be created and returned to the CLI. You can create project-specific configurations with the `--project-name` flag, which can be used in any context. To create an initial configuration: - $ stripe login --project-name=rocket-rides +```sh +$ stripe login --project-name=rocket-rides +``` If you do not provide the `--project-name` flag for a command, it will default to the global configuration. @@ -63,11 +69,13 @@ All configurations are stored in `~/.config/stripe/config.toml` but you can use You can also provide an API key manually by passing the `--interactive` flag: - $ stripe login --interactive - Enter your API key: sk_test_foobar - Your API key is: sk_test_**obar - How would you like to identify this device in the Stripe Dashboard? [default: st-tomer1] - You're configured and all set to get started +```sh +$ stripe login --interactive +Enter your API key: sk_test_foobar +Your API key is: sk_test_**obar +How would you like to identify this device in the Stripe Dashboard? [default: st-tomer1] +You're configured and all set to get started +``` ### `listen` @@ -76,23 +84,30 @@ The `listen` command establishes a direct connection with Stripe, delivering web > **Note:** You do not need to configure any webhook endpoints in your Dashboard to receive webhooks with the CLI. By default, `listen` accepts all webhook events displays them in your terminal. To forward events to your local app, use the `--forward-to` flag with the location: - - `--forward-to localhost:9000` - - `--forward-to https://example.com/hooks` + +* `--forward-to localhost:9000` +* `--forward-to https://example.com/hooks` Using `--forward-to` will return a [webhook signing secret](https://stripe.com/docs/webhooks/signatures), which you can add to your application's configuration: - $ stripe listen --forward-to https://example.com/hooks - > Ready! Your webhook signing secret is whsec_oZ8nus9PHnoltEtWZ3pGITZdeHWHoqnL (^C to quit) +```sh +$ stripe listen --forward-to https://example.com/hooks +> Ready! Your webhook signing secret is whsec_oZ8nus9PHnoltEtWZ3pGITZdeHWHoqnL (^C to quit) +``` The webhook signing secret provided will not change between restarts to the `listen` command. You can specify which events you want to listen to using `--events` with a comma-separated [list of Stripe events](https://stripe.com/docs/api/events/list). - $ stripe listen --events=payment_intents.created,payment_intents.updated +```sh +$ stripe listen --events=payment_intents.created,payment_intents.updated +``` You may have webhook endpoints you've already configured with specific Stripe events in your Dashboard. The Stripe CLI can automatically listen to those events with the `--load-from-webhooks-api` flag, used alongside the `--forward-to` flag. This will read any endpoints configured in test mode for your account and forward associated events to the provided URL: - $ stripe listen --load-from-webhooks-api --forward-to https://example.com/hooks +```sh +$ stripe listen --load-from-webhooks-api --forward-to https://example.com/hooks +``` > **Note:** You will receive events for all interactions on your Stripe account. There is currently no way to limit events to only those that a specific user created. @@ -102,11 +117,15 @@ The CLI has three commands that let you interact with the Stripe API in test mod For example, you can retrieve a specific charge: - $ stripe get /charges/ch_1EGYgUByst5pquEtjb0EkYha +```sh +$ stripe get /charges/ch_1EGYgUByst5pquEtjb0EkYha +``` You can also pass data in using the `-d` flag: - $ stripe post /charges -d amount=100 -d source=tok_visa -d currency=usd +``` +$ stripe post /charges -d amount=100 -d source=tok_visa -d currency=usd +``` These commands support many of the features on the Stripe API (e.g. selecting a version, pagination, and expansion) through command-line flags, so you won't need to provide specific headers. @@ -123,12 +142,13 @@ These commands support many of the features on the Stripe API (e.g. selecting a | get | `-a`, `--starting-after` | Retrieve the next page in the list. This is a cursor for pagination and should be an object ID | `--starting-after cust_1234abc` | | get | `-b`, `--ending-before` | Retrieve the previous page in the list. This is a cursor for pagination and should be an object ID | `--ending-before cust_1234abc` | - -You can pipe the output of these commands to other tools. For example, you could use `[jq](https://stedolan.github.io/jq/)` to extract information from JSON the API returns, and then use that information to trigger other API requests. +You can pipe the output of these commands to other tools. For example, you could use [jq](https://stedolan.github.io/jq/) to extract information from JSON the API returns, and then use that information to trigger other API requests. Here’s a simple example that lists `past_due` subscriptions, extracts the IDs, and cancels those subscriptions: - $ stripe get /subscriptions -d status=past_due | jq ".data[].id" | xargs -I % -p stripe delete /subscriptions/% +```sh +$ stripe get /subscriptions -d status=past_due | jq ".data[].id" | xargs -I % -p stripe delete /subscriptions/% +``` ### `trigger` @@ -136,26 +156,28 @@ The CLI will allow you to trigger a few test webhook events to conduct local tes The webhook events we currently support are: -- `charge.captured` -- `charge.failed` -- `charge.succeeded` -- `customer.created` -- `customer.updated` -- `customer.source.created` -- `customer.source.updated` -- `customer.subscription.updated` -- `invoice.created` -- `invoice.finalized` -- `invoice.payment_succeeded` -- `invoice.updated` -- `payment_intent.created` -- `payment_intent.payment_failed` -- `payment_intent.succeeded` -- `payment_method.attached` +* `charge.captured` +* `charge.failed` +* `charge.succeeded` +* `customer.created` +* `customer.updated` +* `customer.source.created` +* `customer.source.updated` +* `customer.subscription.updated` +* `invoice.created` +* `invoice.finalized` +* `invoice.payment_succeeded` +* `invoice.updated` +* `payment_intent.created` +* `payment_intent.payment_failed` +* `payment_intent.succeeded` +* `payment_method.attached` To trigger an event, run: - $ stripe trigger +```sh +$ stripe trigger +``` ## Developing the Stripe CLI @@ -163,10 +185,14 @@ To trigger an event, run: The Stripe CLI is built using Go. To download and compile the source code, run: - $ go get -u github.com/stripe/stripe-cli/... +```sh +$ go get -u github.com/stripe/stripe-cli/... +``` ### Tests You can run tests with: - $ go test ./... +```sh +$ make test +```