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

Test disbursement objects throw AttributeError for is_credit() and is_debit() #126

Open
bcdickinson opened this issue Feb 19, 2021 · 3 comments
Labels

Comments

@bcdickinson
Copy link

General information

  • SDK/Library version: 3.59.0
  • Environment: Local testing
  • Language, language version, and OS: Python 3.8.6 (python:3.8-buster Docker image)

Issue description

Test disbursement webhook notifications are missing the disbursement_type attribute, causing the is_credit() and is_debit() methods to throw AttributeErrors:

>>> webhook_notification = self.gateway.webhook_testing.sample_notification(
>>>   braintree.WebhookNotification.Kind.Disbursement,
>>>   "test_disbursement_id",
>>> )
>>> webhook_notification.disbursement.is_credit()                                                                     
Traceback (most recent call last):                                                               
  File "<pudb command line>", line 1, in <module>                                                
  File "/usr/local/lib/python3.8/site-packages/braintree/disbursement.py", line 27, in is_credit 
    return self.disbursement_type == Disbursement.Type.Credit                                    
AttributeError: 'Disbursement' object has no attribute 'disbursement_type'                       
@crookedneighbor
Copy link
Contributor

Would you like to open a PR to fix this? If not, we'll add it to our backlog to fix. Thanks for bringing this to our attention!

@bcdickinson
Copy link
Author

Thanks for getting back to me.

I held off submitting a PR for this while I waited for some real webhook data to come through from our sandbox environment. It seems like the disbursement type field is coming through as None, whereas the tests and documentation imply that it should always be "credit" or "debit".

I'm not sure which bit is incorrect, the documentation and the tests or the API response! I think I'll have to leave this one to you.

Here's an example of a parsed notification we received:

<WebhookNotification {kind: 'disbursement', timestamp: datetime.datetime(2021, 2, 23, 6, 20, 56), subject: {'disbursement': {'id': 'abcdef', 'merchant_account': {'status': 'active', 'id': '<snip>', 'currency_iso_code': 'GBP', 'default': True, 'sub_merchant_account': False}, 'exception_message': None, 'amount': '10.00', 'disbursement_date': datetime.date(2021, 2, 23), 'disbursement_type': None, 'follow_up_action': None, 'success': True, 'retry': False, 'transaction_ids': ['<snip>']}}} at 140366520028080>

@hollabaq86
Copy link

for internal tracking, ticket 842

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

No branches or pull requests

3 participants