arlyon / async-stripe

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

Certain feature combination does not compile #137

Open dthul opened 2 years ago

dthul commented 2 years ago

I'm using the following line in my Cargo.toml:

async-stripe = { version = "0.13", default-features = false, features = ["runtime-tokio-hyper-rustls", "billing", "webhook-events"] }

and this is the compile error I get:

   Compiling async-stripe v0.13.0
error[E0432]: unresolved import `crate::resources::CheckoutSessionItem`
  --> /home/dthul/.cargo/registry/src/github.com-1ecc6299db9ec823/async-stripe-0.13.0/src/resources/generated/quote.rs:11:14
   |
11 |     Account, CheckoutSessionItem, Currency, Customer, Discount, Invoice,
   |              ^^^^^^^^^^^^^^^^^^^
   |              |
   |              no `CheckoutSessionItem` in `resources`
   |              help: a similar name exists in the module: `CheckoutSession`

As far as I can tell CheckoutSessionItem will only be re-exported from crate::resources when the checkout Cargo feature is activated. As a quick fix I changed my dependency line to:

async-stripe = { version = "0.13", default-features = false, features = ["runtime-tokio-hyper-rustls", "billing", "webhook-events", "checkout"] }
arlyon commented 2 years ago

Thanks for the report. I'll have a look and see if we can either a) rework the deps or b) at least document this requirement.

arlyon commented 2 years ago

We are planning on addressing this issue with 0.15 where we will split out the codegen into crates. This will make the dependencies much more explicit. Stay tuned.

fancywriter commented 2 years ago

Hi @arlyon I am experiencing similar issue as @dthul .

And also trying to undestand which feature I have to enable to make use stripe::TerminalLocation; to compile, it complains

6 | use stripe::TerminalLocation;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^ no `TerminalLocation` in the root

I have noticed that this code is generated https://github.com/arlyon/async-stripe/blob/ca5269ebcf9cbd7005f3fecedc63cc31718680a6/src/resources/generated/terminal_location.rs

Tried to add "terminal" or "terminal-location" features, but none of them worked:

the package `my_example` depends on `async-stripe`, with features: `terminal-location` but `async-stripe` does not have these features.
arlyon commented 2 years ago

Hi

The terminal APIs are currently not exported (and untested). I will write a PR to add them and you can provide feedback. Everything should 'just work' after that.

See here for a list of unexported APIs (updated weekly with): https://github.com/arlyon/async-stripe/pull/216

I am adding terminal support in this PR: https://github.com/arlyon/async-stripe/pull/221

arlyon commented 2 years ago

The pr is merged let me know if there are any issues with the terminal API.

dthul commented 2 years ago

When I updated to v0.15 I ran into a new but similar compile issue. The Cargo.toml line I used:

async-stripe = { version = "0.15", default-features = false, features = ["runtime-tokio-hyper-rustls", "billing", "webhook-events", "checkout"] }

which leads to this error:

    Checking async-stripe v0.15.0
error[E0412]: cannot find type `AccountCapabilities` in this scope
   --> /home/dthul/.cargo/registry/src/github.com-1ecc6299db9ec823/async-stripe-0.15.0/src/resources/webhook_events.rs:444:25
    |
444 |     AccountCapabilities(AccountCapabilities),
    |                         ^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
help: there is an enum variant `crate::EventObject::AccountCapabilities`; try using the variant's enum
    |
444 |     AccountCapabilities(crate::EventObject),
    |                         ~~~~~~~~~~~~~~~~~~

and the new line which makes it work (by adding the "connect" feature which will re-export the AccountCapabilities struct):

async-stripe = { version = "0.15", default-features = false, features = ["runtime-tokio-hyper-rustls", "billing", "webhook-events", "checkout", "connect"] }
cortopy commented 2 years ago

I also bumped into this. I only need the webhook-events feature in addition to runtime.

In my case this works

async-stripe = { version = "0.15.0", default-features = false, features = ["runtime-tokio-hyper", "webhook-events", "connect", "checkout"]}

It seems like webhook-events should also activate connect and checkout

mzeitlin11 commented 2 years ago

Copying from #238: after updating to 0.15.0, a set of features that built fine in 0.14.1 now doesn't compile. A minimal Cargo.toml which compiles for 0.14 but not 0.15.0:

[dependencies]
async-stripe = {version = "0.15.0", default-features = false, features = ["runtime-tokio-hyper", "webhook-events", "checkout"]}

The compilation error:

error[E0412]: cannot find type `AccountCapabilities` in this scope
   --> /Users/matthewzeitlin/.cargo/registry/src/github.com-1ecc6299db9ec823/async-stripe-0.15.0/src/resources/webhook_events.rs:444:25
    |
444 |     AccountCapabilities(AccountCapabilities),
    |                         ^^^^^^^^^^^^^^^^^^^ not found in this scope
    |
help: there is an enum variant `crate::EventObject::AccountCapabilities`; try using the variant's enum
    |
444 |     AccountCapabilities(crate::EventObject),
    |                         ~~~~~~~~~~~~~~~~~~

Adding the feature connect fixes this compilation error.

lgarron commented 7 months ago

I ran into this today with:

# Cargo.toml
async-stripe = { version = "0.34.1", default-features = false, features = ["runtime-blocking-rustls", "billing"] }
use stripe::{ListSubscriptions, StripeError, Subscription};
const TEST_SECRET_KEY: &str = "sk_test_…";

use stripe::{ListSubscriptions, StripeError, Subscription};

async fn test() -> Result<(), StripeError> {
    let client = stripe::Client::new(TEST_SECRET_KEY);
    let s = Subscription::list(&client, &ListSubscriptions::default())?;
    dbg!(s);
    Ok(())
}

This results in:

error[E0432]: unresolved import `crate::resources::CheckoutSessionItem`
  --> /…/.cache/cargo/registry/src/index.crates.io-6f17d22bba15001f/async-stripe-0.34.1/src/resources/generated/quote.rs:11:27
   |
11 |     Account, Application, CheckoutSessionItem, ConnectAccountReference, Currency, Customer,
   |                           ^^^^^^^^^^^^^^^^^^^
   |                           |
   |                           no `CheckoutSessionItem` in `resources`
   |                           help: a similar name exists in the module: `CheckoutSession`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `async-stripe` (lib) due to 1 previous error