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

stripe fixtures command does not read .env file #1179

Open
sovetski opened this issue May 4, 2024 · 0 comments
Open

stripe fixtures command does not read .env file #1179

sovetski opened this issue May 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@sovetski
Copy link

sovetski commented May 4, 2024

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 sovetski added the bug Something isn't working label May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant