stripe / stripe-python

Python library for the Stripe API.
https://stripe.com
MIT License
1.64k stars 418 forks source link

unknown parameter: stripe_acccount when creating subscription for a connected account #1333

Closed rebkwok closed 3 months ago

rebkwok commented 3 months ago

Describe the bug

The docs state that subscriptions can be create for connected accounts using the stripe_account parameter:

However, using the code from the docs returns an InvalidRequestError: ... Received unknown parameter: stripe_acccount.

Is it possible to create a subscription for a connected account via the python API?

To Reproduce

  1. Create a connected account
  2. Create a customer for the connected account
  3. Create a product and price for the connected account
  4. Create a subscription for the connected account as per docs
    stripe.Subscription.create(
    customer='{{CUSTOMER_ID}}',
    items=[{"price": '{{PRICE_ID}}'}],
    expand=["latest_invoice.payment_intent"],
    stripe_account='{{CONNECTED_ACCOUNT_ID}}',
    )

Expected behavior

Subscription is created for customer on the connecgted account

Actual behaviour:

InvalidRequestError: ... Received unknown parameter: stripe_acccount

Code snippets

No response

OS

macOS

Language version

Python 3.11

Library version

stripe-python v9.7.0

API version

2024-04-10

Additional context

No response

remi-stripe commented 3 months ago

@rebkwok I tried that exact code you have with the hardcoded values on v9.7.0 and the error I get is

stripe._error.PermissionError: The provided key 'sk_test_********************A6xl' does not have access to account '{{CONNECTED_ACCOUNT_ID}}' (or that account does not exist). Application access may have been revoked.

That error is expected since it's not a real account id but it confirms the code runs just fine and stripe_account is turned into the Stripe-Account header internally as expected.

Can you provide a simple end-to-end reproduction of the exact bug you are experiencing? Is it possible something else in your code is causing this error? Can you also share an exact request id req_123 which would be in the error returned so that I can look deeper?

rebkwok commented 3 months ago

@remi-stripe I have run through all my steps again in a shell and have not run into the same issue. It was due to a dumb typo in my code; sorry for the false alarm. But thanks so much for the quick response, it is really appreciated :). I will close the issue.