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

actions: fix sync_account_from_stripe_data #496

Closed
wants to merge 4 commits into from

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Nov 15, 2017

No description provided.

"transfers_enabled" is not in there by default?!
Might only be there after/when rejecting an account
(https://stripe.com/docs/api#reject_account).

Adding "payouts_enabled" and "support_address".
"email":"[email protected]",
"transfers_enabled":true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fails because "transfers_enabled" is expected to be there, but is not.
Can you shed some light, @lukeburden ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://stripe.com/docs/upgrades#2017-04-06

it has been renamed to payouts_enabled

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another migration is on its way

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find.
Full docs: https://stripe.com/docs/transfer-payout-split (the renaming is mentioned at the end).

@blueyed
Copy link
Contributor Author

blueyed commented Nov 15, 2017

mccabe complains now.

'sync_account_from_stripe_data' is too complex (11)

workaround:

diff --git a/pinax/stripe/actions/accounts.py b/pinax/stripe/actions/accounts.py
index 9d379fb..c3e1686 100644
--- a/pinax/stripe/actions/accounts.py
+++ b/pinax/stripe/actions/accounts.py
@@ -113,9 +113,8 @@ def sync_account_from_stripe_data(data, user=None):
     else:
         top_level_attrs = common_attrs
 
-    for a in top_level_attrs:
-        if a in data:
-            setattr(obj, a, data.get(a))
+    for a in [x for x in top_level_attrs if x in data]:
+        setattr(obj, a, data.get(a))
 
     # that's all we get for standard and express accounts!
     if data["type"] != "custom":

I feel like this is actually not better though.

Let's split the function, or ignore mccabe here?

@blueyed
Copy link
Contributor Author

blueyed commented Nov 15, 2017

I am closing this, since it conflicts with lock8#73 by itself, and we should have a single PR including both probably?!

@blueyed blueyed closed this Nov 15, 2017
@blueyed blueyed deleted the fix-sync-account branch November 15, 2017 19:35
@paltman
Copy link
Member

paltman commented Nov 15, 2017

@blueyed I️ like McCabe as a guide but we don’t need to be slave to it. If it’s not obvious a way to easily make better let’s ignore.

@blueyed
Copy link
Contributor Author

blueyed commented Nov 16, 2017

Hard to ignore it though if the lint job fails then..

But I guess you mean to ignore it for this function then only, which makes sense.

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 this pull request may close these issues.

None yet

3 participants