Skip to content

gateway.transaction.find raises a TypeError when initialised with client_id and secret #128

@jvn145

Description

@jvn145

General information

  • SDK/Library version: 4.6.0
  • Environment: Sandbox
  • Language, language version, and OS: Python 3.9.1 on a python:alpine docker container

Issue description

When I try and gateway.transaction.find a transaction using a gateway that was initialised with a client_id and secret, I receive a TypeError "can only concatenate str (not "NoneType") to str".

Had a look, this happens because the BraintreeGateway.merchant_id is not set if you initialise it using a client_id and secret.

Steps to reproduce:

# gateway using my credentials
gateway = braintree.BraintreeGateway(
    client_id=os.getenv('BT_CID'), 
    client_secret=os.getenv('BT_SECRET')
)

result = gateway.transaction.sale({
    "amount": '1.00',
    "payment_method_nonce": 'fake-valid-nonce',
    "options": {
        "submit_for_settlement": True
    }
})

transaction = result.transaction

result = gateway.transaction.find(transaction.id)

Traceback:

Traceback (most recent call last):
  File "/test.py", line 89, in <module>
    result = my_gateway.transaction.sale({
  File "/usr/local/lib/python3.9/site-packages/braintree/transaction_gateway.py", line 84, in sale
    return self.create(params)
  File "/usr/local/lib/python3.9/site-packages/braintree/transaction_gateway.py", line 31, in create
    return self._post("/transactions", {"transaction": params})
  File "/usr/local/lib/python3.9/site-packages/braintree/transaction_gateway.py", line 168, in _post
    response = self.config.http().post(self.config.base_merchant_path() + url, params)
  File "/usr/local/lib/python3.9/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions