Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested retrieve doesn't accept stripe_account #609

Closed
ryancausey opened this issue Sep 8, 2019 · 4 comments · Fixed by #610
Closed

Nested retrieve doesn't accept stripe_account #609

ryancausey opened this issue Sep 8, 2019 · 4 comments · Fixed by #610

Comments

@ryancausey
Copy link

During testing the python API, it appears that making a nested retrieve call doesn't accept the stripe_account as a parameter. Is this expected behavior? Does the nested retrieve use the parent stripe object's stripe_account it was retrieved with?

In this case I was retrieving sources for a customer. To reproduce:

  1. retrieve a customer object using stripe_account=<account id>.
  2. attempt to retrieve the customer.sources passing stripe_account=<account id>
  3. expected to work, actual result is below:
>>> customer_stripe.sources.retrieve(customer_stripe.id, stripe_account=account.id)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/ryan/.local/share/virtualenvs/django-matsite-MBWSvxvE/lib/python3.7/site-packages/stripe/api_resources/list_object.py", line 41, in retrieve
    return self.request("get", url, params)
  File "/home/ryan/.local/share/virtualenvs/django-matsite-MBWSvxvE/lib/python3.7/site-packages/stripe/stripe_object.py", line 243, in request
    response, api_key = requestor.request(method, url, params, headers)
  File "/home/ryan/.local/share/virtualenvs/django-matsite-MBWSvxvE/lib/python3.7/site-packages/stripe/api_requestor.py", line 121, in request
    resp = self.interpret_response(rbody, rcode, rheaders)
  File "/home/ryan/.local/share/virtualenvs/django-matsite-MBWSvxvE/lib/python3.7/site-packages/stripe/api_requestor.py", line 372, in interpret_response
    self.handle_error_response(rbody, rcode, resp.data, rheaders)
  File "/home/ryan/.local/share/virtualenvs/django-matsite-MBWSvxvE/lib/python3.7/site-packages/stripe/api_requestor.py", line 151, in handle_error_response
    raise err
stripe.error.InvalidRequestError: Request req_6OGzRcJ6BH8uyT: Received unknown parameter: stripe_account
@ob-stripe
Copy link
Contributor

ob-stripe commented Sep 9, 2019

Hi @ryancausey, thanks for the report. Indeed, it looks like the retrieve method on list objects does not support the stripe_account parameter (or other header parameters like stripe_version).

We'll work on a fix, but note that we no longer recommend using instance methods on list objects. Instead, you can retrieve nested resources by using the static methods on the parent resource, e.g. to retrieve a card:

source = stripe.Customer.retrieve_source('cus_123', 'card_123', stripe_account='acct_123')

@ryancausey
Copy link
Author

Thanks for the response @ob-stripe. Are these methods being deprecated?

@ob-stripe
Copy link
Contributor

We might remove them in a future (major) version of the library, but haven't made firm plans yet. We recommend using the static methods because they avoid making unnecessary requests (e.g. you don't need to retrieve the customer object first to access a card on the customer if you already have the customer ID and the card ID in your database).

@ob-stripe
Copy link
Contributor

Just released stripe-python 2.36.0. The create, retrieve and list instance methods on ListObject now support header parameters: api_key, stripe_account, stripe_version and idempotency_key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants