stripe/stripe-cli

stripe fixtures command does not read .env file

Opened this issue · 1 comments

Issue

I am running stripe fixtures ./fixtures.json, and it returns:

Setting up fixture for: customer
Running fixture for: customer
Setting up fixture for: subscription
Running fixture for: subscription
Request failed, status=400, body={
  "error": {
    "code": "resource_missing",
    "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
    "message": "No such price: '${.env:PRICE_ID}'",
    "param": "items[0][price]",
    "request_log_url": "https://dashboard.stripe.com/test/logs/xxx",
    "type": "invalid_request_error"
  }
}

I have PRICE_ID set in my .env and .env.local file.
My fixtures.json is:

{
  "_meta":{
    "template_version":0
  },
  "fixtures":[
    {
      "name":"customer",
      "path":"/v1/customers",
      "method":"post",
      "params":{
        "name":"John Doe",
        "email":"johndoe@test.com",
        "source":"tok_visa",
        "address":{
          "line1":"1 Main Street",
          "city":"New York"
        }
      }
    },
    {
      "name":"subscription",
      "path":"/v1/subscriptions",
      "method":"post",
      "params":{
        "customer":"${customer:id}",
        "items":[
          {
            "price":"${.env:PRICE_ID}"
          }
        ]
      }
    }
  ]
}

I followed the explanation from official documentation: https://docs.stripe.com/cli/fixtures

It says:

Use ${.env:PHONE} to access environment variables (supports .env files).

How stripe knows which .env file to read? Generally we commit .env file with some examples with empty values, and the real values are set in .env.local, .env.test etc.

Expected Behavior

It should read the PRICE_ID from my .env or .env.local, .env.test etc.

Environment

Windows

@sovetski In my case the Stripe.CLI my fixture and .env file all live in the same directory. When running the command I think it uses the file in that directory.