arlyon / async-stripe

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

SubscriptionPaymentBehaviour not exposed properly #306

Closed Skydive closed 1 year ago

Skydive commented 1 year ago

Describe the bug

I'm getting a nasty compiler error while compiling. I'm trying to set the payment_behaviour field of a new subscription as documented in the stripe guide.

Error[E308] mismatched types
expected enum `stripe::generated::billing::subscription::SubscriptionPaymentBehavior`,
found enum `stripe::SubscriptionPaymentBehavior`

I can also see in the automatically generated API documentation, there is something wrong in the CreateSubscription struct. I cannot access the SubscriptionPaymentBehaviour struct from it. Perhaps this is related to the problem I have.

To Reproduce

Fetch latest version of async-stripe from github. Attempt to set the payment_behaviour field of a CreateSubscription struct.

Expected behavior

Expecting normal compilation

Code snippets

let mut params = CreateSubscription::new(customer.id);
params.items = Some(vec![CreateSubscriptionItems {
    price: Some(data.price_id.to_owned()),
    ..Default::default()
}]);
params.payment_settings = Some(CreateSubscriptionPaymentSettings {
    save_default_payment_method: Some(CreateSubscriptionPaymentSettingsSaveDefaultPaymentMethod::OnSubscription),
    ..Default::default()
});
params.payment_behavior = Some(SubscriptionPaymentBehavior::DefaultIncomplete); // <------
params.expand = &["latest_invoice.payment_intent"];
Subscription::create(&STRIPE_CLIENT, params).await

Cargo.toml

[dependencies]
async-stripe = { git = "https://github.com/arlyon/async-stripe", default-features = false, features = ["runtime-tokio-hyper", "billing", "checkout"]}

OS

Linux 6.0.2

Rust version

rustc 1.65.0 (897e37553 2022-11-02)

Library version

async-stripe (latest, branch master & 0.15.0)

API version

2022-11-15

Additional context

No response

arlyon commented 1 year ago

Hi, we have an issue with name clashing which is detailed in this issue: https://github.com/arlyon/async-stripe/issues/154 due to the way rust handles aliasing. I am planning on a breaking change soon to resolve this by renaming types with clashing names, but have no timeline just yet

You should be able to just import the appropriate variant from the generated module directly.

- use stripe::SubscriptionPaymentBehavior;
+ use stripe::generated::billing::subscription::SubscriptionPaymentBehavior;
arlyon commented 1 year ago

I am going to close this with the expectation that it is a duplicate of the above issue. If that is not the case, please leave a comment :)