stripe / stripe-cli

A command-line tool for Stripe
https://stripe.com/docs/stripe-cli
Apache License 2.0
1.57k stars 362 forks source link

Stripe CLI: Trigger of "subscription.payment_succeeded" does not work #1116

Open DenisKnecht02 opened 10 months ago

DenisKnecht02 commented 10 months ago

Issue

I wanted to test a successful payment on a subscription by triggering the event via Stripe CLI. I talked to a developer in the Developer Discord. He tested it on MacOS, where it worked. I used CLI versions v1.17.0 and v1.17.1 and API version 2023-08-16. When editing the trigger, it shows the following fixtures etc:

{
  "_meta": {
    "template_version": 0
  },
  "fixtures": [
    {
      "name": "payment_method",
      "path": "/v1/payment_methods",
      "method": "post",
      "params": {
        "type": "card",
        "card": {
          "number": "4242424242424242",
          "exp_month": 10,
          "exp_year": 2026,
          "cvc": 314
        }
      }
    },
    {
      "name": "customer",
      "path": "/v1/customers",
      "method": "post",
      "params": {
        "name": "SubscriptionTestCustomer",
        "description": "(created by Stripe CLI)"
      }
    },
    {
      "name": "attach_payment_method",
      "path": "/v1/payment_methods/${payment_method:id}/attach",
      "method": "post",
      "params": {
        "customer": "${customer:id}"
      }
    },
    {
      "name": "default_payment_method",
      "path": "/v1/customers/${customer:id}",
      "method": "post",
      "params": {
        "invoice_settings": {
          "default_payment_method": "${payment_method:id}"
        }
      }
    },
    {
      "name": "product",
      "path": "/v1/products",
      "method": "post",
      "params": {
        "name": "SubscriptionTestProduct",
        "description": "(created by Stripe CLI)"
      }
    },
    {
      "name": "price",
      "path": "/v1/prices",
      "method": "post",
      "params": {
        "nickname": "SubscriptionTestPrice",
        "product": "${product:id}",
        "unit_amount": 2000,
        "currency": "usd",
        "recurring": {
          "interval": "month"
        }
      }
    },
    {
      "name": "subscription",
      "path": "/v1/subscriptions",
      "method": "post",
      "params": {
        "customer": "${customer:id}",
        "items": [
          {
            "price": "${price:id}"
          }
        ]
      }
    },
    {
      "name": "invoice",
      "path": "/v1/invoices/${subscription:latest_invoice}",
      "method": "get",
      "params": {}
    }
  ]
}

Expected Behavior

Successful trigger of this event.

Steps to reproduce

  1. Open terminal
  2. Type stripe login
  3. Type stripe trigger subscription.payment_succeeded

Traceback

The logs are:

Setting up fixture for: payment_method
Running fixture for: payment_method
Trigger failed: Request failed, status=402, body={
  "error": {
    "message": "Sending credit card numbers directly to the Stripe API is generally unsafe. We suggest you use test tokens that map to the test card you are using, see https://stripe.com/docs/testing. To enable raw card data APIs in test mode, see https://support.stripe.com/questions/enabling-access-to-raw-card-data-apis.",
    "request_log_url": "https://dashboard.stripe.com/test/logs/req_kmBjJE8QY2N1KV?t=1692782692",
    "type": "invalid_request_error"
  }
}

Environment

Windows 10 Home 22H2

tucker-altir commented 10 months ago

I'm seeing this error as well, using the same cli and api versions as @DenisKnecht02.

strangely enough, this also triggered a warning message from Stripe to our team as well:

image
emilioiz commented 10 months ago

I'm seeing this error as well, using the same cli and api versions as @DenisKnecht02.

Environment Apple M2 Max macOS Ventura 13.4.1

K4sku commented 9 months ago

I'm having the same issue, MacOS 11.7.1 with event subscription.payment_failed

Kirillpt commented 8 months ago

The same issue:

$ stripe stripe trigger subscription.payment_succeeded

Setting up fixture for: payment_method
Running fixture for: payment_method
Trigger failed: Request failed, status=402, body={
  "error": {
    "message": "Sending credit card numbers directly to the Stripe API is generally unsafe. We suggest you use test tokens that map to the test card you are using, see https://stripe.com/docs/testing. To enable raw card data APIs in test mode, see https://support.stripe.com/questions/enabling-access-to-raw-card-data-apis.",
    "request_log_url": "https://dashboard.stripe.com/test/logs/req_wWx************",
    "type": "invalid_request_error"
  }
}

stripe version 1.17.2

Vladlysenko75 commented 4 months ago

Update Stripe version with brew install stripe/stripe-cli/stripe.

I was on 1.13.10 version and got same errors, updated to 1.19.2 and it's working now.