braintree / braintree_python

Braintree Python library
https://developer.paypal.com/braintree/docs/start/overview
MIT License
241 stars 155 forks source link

TypeError: can only concatenate str (not "NoneType") to str #134

Closed tkansara closed 3 years ago

tkansara commented 3 years ago

General information

Issue description

import braintree
from datetime import datetime
from datetime import timedelta
import csv
from collections import OrderedDict
gateway = braintree.BraintreeGateway(
    gateway=braintree.BraintreeGateway(
        braintree.Configuration(
            environment=braintree.Environment.Production,
            merchant_id='*************',
            public_key='***********',
            private_key='**************'
        )
    )

)
print(gateway)
N = 1
date_N_days_ago = datetime.now() - timedelta(days=N)
print("Date Set", datetime.now(), "Yesterday Date", date_N_days_ago)
print("test")
search_results = gateway.transaction.search([braintree.TransactionSearch.customer_email == "someemail@gmail.com"])
for transaction in search_results.items:
    print(transaction)

When I run the above code, which seems to be from the BT dev page, I get the following error:

Traceback (most recent call last): File "C:\Courses\BT\main.py", line 26, in <module> search_results = gateway.transaction.search([braintree.TransactionSearch.customer_email == "buamabo@gmail.com"]) File "C:\Courses\BT\venv\lib\site-packages\braintree\transaction_gateway.py", line 98, in search response = self.config.http().post(self.config.base_merchant_path() + "/transactions/advanced_search_ids", {"search": self.__criteria(query)}) File "C:\Courses\BT\venv\lib\site-packages\braintree\configuration.py", line 113, in base_merchant_path return "/merchants/" + self.merchant_id TypeError: can only concatenate str (not "NoneType") to str

tkansara commented 3 years ago

Please delete this. I realized I was calling the gateway statement twice. Thanks