wyyerd / stripe-rs

Rust API bindings for the Stripe HTTP API.
Apache License 2.0
224 stars 88 forks source link

Fix bug deserializing subscriptions with metered pricing #55

Closed Jayshua closed 5 years ago

Jayshua commented 5 years ago

Subscription plans can either have licensed or metered usage. I ran into a few deserialization errors while using metered usage:

  1. The amount field of a Plan can be null if the plan uses tiered metered pricing. (I didn't keep the actual error for this one. It was basically error deserializing null to u64.)

  2. The quantity field of a SubscriptionItem does not exist if the subscription uses metered pricing. Error was:

    Deserialize(Error("missing field `quantity`", line: 120, column: 13))

I don't actually use metered pricing so I'm not sure if there might be other issues. These errors just came up on some test data while I was evaluating it.

kestred commented 5 years ago

👍 .

Highlights the need to use stripe's mock server for testing. Thank you for the PR.