Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support v2 openapi #1298

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

support v2 openapi #1298

wants to merge 14 commits into from

Conversation

etsai2-stripe
Copy link
Contributor

@etsai2-stripe etsai2-stripe commented Feb 1, 2025

Reviewers

r? @
cc @stripe/developer-products

Summary

main help text

$ stripe-dev help
The official command-line tool to interact with Stripe.

Usage:
  stripe [command]

Webhook commands:
  listen                             Listen for webhook events
  trigger                            Trigger test webhook events

Stripe commands:
  logs                               Interact with Stripe API request logs

Resource commands:
  get                           Quickly retrieve resources from Stripe
  charges                       Make requests (capture, create, list, etc) on charges
  customers                     Make requests (create, delete, list, etc) on customers
  payment_intents               Make requests (cancel, capture, confirm, etc) on payment intents
  ...                           To see more resource commands, run `stripe resources help`
  v2                            To see only v2 resource commands, run `stripe v2 help`

Other commands:
  community                          Chat with Stripe engineers and other developers
  completion                         Generate bash and zsh completion scripts
  config                             Manually change the config values for the CLI
  feedback                           Provide us with feedback on the CLI
  fixtures                           Run fixtures to populate your account with data
  help                               Help about any command

stripe v2 help

$ stripe-dev v2 help
Usage:
  stripe v2 <resource> <operation> [parameters...]

Available Resources:
  billing
  core

Flags:
  -h, --help   help for v2

Global Flags:
      --api-key string        Your API key to use for the command
      --color string          turn on/off color output (on, off, auto)
      --config string         config file (default is $HOME/.config/stripe/config.toml)
      --device-name string    device name
      --log-level string      log level (debug, info, trace, warn, error) (default "info")
  -p, --project-name string   the project name to read from for config (default "default")

Use "stripe v2 [command] --help" for more information about a command.

run v2 command - GET (redacted)

$ stripe-dev v2 core event_destinations list --api-key sk_test_zzz
{
  "data": [
    {
      "id": "ed_test_zzz",
      "object": "v2.core.event_destination",
      "created": "2024-08-28T00:20:32.755Z",
      "description": "",
      "enabled_events": [
        "v1.billing.meter.no_meter_found",
        "v1.billing.meter.error_report_triggered"
      ],
      "event_payload": "thin",
      "events_from": ["self"],
      "livemode": false,
      "metadata": {},
      "name": "asdf",
      "snapshot_api_version": null,
      "status": "enabled",
      "status_details": null,
      "type": "webhook_endpoint",
      "updated": "2024-11-06T23:19:18.325Z",
      "webhook_endpoint": {
        "signing_secret": null,
        "url": null
      }
    }
  ],
  "next_page_url": null,
  "previous_page_url": null
}

run v2 command - POST (redacted)

$ stripe-dev v2 core event_destinations create --enabled-events "v1.billing.meter.no_meter_found" --event-payload thin --type webhook_endpoint --name created_from_cli --webhook-endpoint.url "https://example.com" --api-key sk_test_zzz
{
  "id": "ed_test_zzz",
  "object": "v2.core.event_destination",
  "created": "2025-02-04T01:43:23.039Z",
  "description": "",
  "enabled_events": ["v1.billing.meter.no_meter_found"],
  "event_payload": "thin",
  "events_from": ["self"],
  "livemode": false,
  "metadata": {},
  "name": "created_from_cli",
  "snapshot_api_version": null,
  "status": "enabled",
  "status_details": null,
  "type": "webhook_endpoint",
  "updated": "2025-02-04T01:43:23.046Z",
  "webhook_endpoint": {
    "signing_secret": null,
    "url": null
  }
}

Screenshot 2025-02-03 at 5 44 51 PM

run v2 command without secret key

$ stripe-dev v2 core event_destinations list
V2 commands must be run with a secret API key (starts with 'sk_'), status=401, body={
  "error": {
    "message": "The request does not have valid authentication credentials.",
    "code": "unauthorized"
  }
}

v1 commands remains working

$ stripe-dev customers create
{
  "id": "cus_Rhk6ySHjz1jXUd",
  "object": "customer",
  "address": null,
  "balance": 0,
  "created": 1738569776,
  "currency": null,
  "default_source": null,
  "delinquent": false,
  "description": null,
  "discount": null,
  "email": null,
  "invoice_prefix": "38E1ED5F",
  "invoice_settings": {
    "custom_fields": null,
    "default_payment_method": null,
    "footer": null,
    "rendering_options": null
  },
  "livemode": false,
  "metadata": {},
  "name": null,
  "next_invoice_sequence": 1,
  "phone": null,
  "preferred_locales": [],
  "shipping": null,
  "tax_exempt": "none",
  "test_clock": null
}

@etsai2-stripe etsai2-stripe requested a review from a team as a code owner February 1, 2025 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants