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

Cannot set price unit_amount to 0 #42

Open
adamstegman opened this issue Feb 1, 2021 · 2 comments · Fixed by bchatelard/terraform-provider-stripe#3 · May be fixed by #49
Open

Cannot set price unit_amount to 0 #42

adamstegman opened this issue Feb 1, 2021 · 2 comments · Fixed by bchatelard/terraform-provider-stripe#3 · May be fixed by #49

Comments

@adamstegman
Copy link

adamstegman commented Feb 1, 2021

When I try to create a price with a unit_amount of 0, or unit_amount_decimal of 0.0, I get the following error:

Error: {"status":400,"message":"If the billing scheme is set to per_unit, the amount parameter must be set.","param":"amount","request_id":"req_abcdefghijklmn","type":"invalid_request_error"}

When I look at Stripe logs, the field is left out of the request entirely:

{
  "active": "true",
  "billing_scheme": "per_unit",
  "currency": "usd",
  "product": "prod_abcdefghijklmn",
  "recurring": {
    "interval": "year",
    "interval_count": "1",
    "usage_type": "licensed"
  }
}

This is incorrect - an amount of 0 is valid and I can use the API directly to create the price.

@adamstegman
Copy link
Author

I'm not familiar with terraform plugins, but looking at

it seems like GetOk incorrectly returns a non-existent value in this case. Maybe GetOkExists should be used instead, since it does not check the zero-value?

adamstegman added a commit to adamstegman/terraform-provider-stripe that referenced this issue Jun 23, 2021
This allows for a `0` price to be set as a price `amount` in Stripe.

`GetOk` considers `0` as a null value for integers, because it's unclear whether it was intentionally set or unset.
`GetOkExists` allows us to get whatever value was set, even if it's `0`.

Fixes franckverrot#42
@adamstegman adamstegman linked a pull request Jun 24, 2021 that will close this issue
adamstegman added a commit to adamstegman/terraform-provider-stripe that referenced this issue Jul 20, 2021
This allows for a `0` price to be set as a price `amount` in Stripe.

`GetOk` considers `0` as a null value for integers, because it's unclear whether it was intentionally set or unset.
`GetOkExists` allows us to get whatever value was set, even if it's `0`.

Fixes franckverrot#42
@KostyaZgara
Copy link

When this fix will be available?

bchatelard pushed a commit to bchatelard/terraform-provider-stripe that referenced this issue Apr 13, 2023
This allows for a `0` price to be set as a price `amount` in Stripe.

`GetOk` considers `0` as a null value for integers, because it's unclear whether it was intentionally set or unset.
`GetOkExists` allows us to get whatever value was set, even if it's `0`.

Fixes franckverrot#42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants