arlyon / async-stripe

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

at_period_end no longer supported in CancelSubscription #419

Closed migueltol22 closed 7 months ago

migueltol22 commented 1 year ago

Describe the bug

Received an error from stripe when setting at_period_end to Some(true)

Looking at the stripe docs this parameter doesn't appear. https://stripe.com/docs/api/subscriptions/cancel.

If we set to None it'll skip serializing so there's a workaround but wanted to surface issue.

Error Message: "code": "parameter_unknown", "doc_url": "https://stripe.com/docs/error-codes/parameter-unknown", "message": "Received unknown parameter: at_period_end", "param": "at_period_end",

To Reproduce

  1. Create Subscription
  2. Cancel Subscription with at_period_end set to Some(true)

Expected behavior

parameter unknown error

Code snippets

StripeSubscription::cancel(
            &stripe_client,
            &subscription_id,
            CancelSubscription {
                at_period_end: Some(true),
            },
        )

OS

linux

Rust version

1.70.0

Library version

rustc 1.70.0

API version

async-stripe 0.22.2

Additional context

No response

migueltol22 commented 1 year ago

Actually if not specified it'll just cancel the subscription immediately instead of waiting until after the trial period

migueltol22 commented 1 year ago

After doing some research it looks like this was changed and instead of delete update needs to be called with the option cancel_at_period_end https://stripe.com/docs/api/subscriptions/update#update_subscription-cancel_at_period_end

arlyon commented 7 months ago

Closed in #411