arlyon / async-stripe

Async (and blocking!) Rust bindings for the Stripe API
https://payments.rs
Apache License 2.0
418 stars 122 forks source link

bug: PriceId can be prefixed with either `price_` or `plan_` but only `price_` is currently valid #470

Closed skeptrunedev closed 6 months ago

skeptrunedev commented 6 months ago

Describe the bug

I was trying to receive a Subscription and could not due to a error serializing or deserializing a request error.

Above where I was getting that error, there was a log saying bad id is: plan_************** (expected: "price_") for PriceId which clued to me into what was likely happening.

From there, I used the CLI to retrieve the sub stripe subscriptions retrieve sub_******************** so I could validate that there was a plan_ value for a price.

Sure enough in the items for the sub, there was:


"price": {
          "id": "plan_**************",
          "object": "price",
          "active": true,
          "billing_scheme": "per_unit",
          "created": 1704826754,
          "currency": "usd",
          "custom_unit_amount": null,
          "livemode": false,
          "lookup_key": null,
          "metadata": {},
          "nickname": null,
          "product": "prod_**************",
          "recurring": {
            "aggregate_usage": null,
            "interval": "month",
            "interval_count": 1,
            "trial_period_days": null,
            "usage_type": "licensed"
          },
          "tax_behavior": "unspecified",
          "tiers_mode": null,
          "transform_quantity": null,
          "type": "recurring",
          "unit_amount": 1200,
          "unit_amount_decimal": "1200"
        },
        "quantity": 1,
        "subscription": "sub_********************",
        "tax_rates": []
      }
    ],
    "has_more": false,
    "total_count": 1,
    "url": "/v1/subscription_items?subscription=sub_********************"
  },

### To Reproduce

1. create a price that is a plan
2. create a subscription for that price
3. retrieve that subscription with `stripe::Subscription::retrieve`

### Expected behavior

I expect that the result of retrieving the subscription can be deserialized. 

### Code snippets

_No response_

### OS

ubuntu 22.04

### Rust version

1.76.0-nightly

### Library version

async-stripe 0.26.0

### API version

2023-10-16

### Additional context

_No response_
arlyon commented 6 months ago

Looks like we are missing the prefix for this id. Easy fix, I'll have a PR up in a few