/usr/lib/python2.7/dist-packages/braintree/configuration.py is in python-braintree 3.4.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | import os
import sys
import braintree
class Configuration(object):
"""
A class representing the configuration of your Braintree account.
You must call configure before any other Braintree operations. ::
braintree.Configuration.configure(
braintree.Environment.Sandbox,
"your_merchant_id",
"your_public_key",
"your_private_key"
)
"""
@staticmethod
def configure(environment, merchant_id, public_key, private_key, **kwargs):
Configuration.environment = environment
Configuration.merchant_id = merchant_id
Configuration.public_key = public_key
Configuration.private_key = private_key
Configuration.default_http_strategy = kwargs.get("http_strategy", None)
Configuration.timeout = kwargs.get("timeout", 60)
Configuration.wrap_http_exceptions = kwargs.get("wrap_http_exceptions", False)
@staticmethod
def for_partner(environment, partner_id, public_key, private_key, **kwargs):
return Configuration(
environment=environment,
merchant_id=partner_id,
public_key=public_key,
private_key=private_key,
http_strategy=kwargs.get("http_strategy", None),
timeout=kwargs.get("timeout", 60),
wrap_http_exceptions=kwargs.get("wrap_http_exceptions", False)
)
@staticmethod
def gateway():
return braintree.braintree_gateway.BraintreeGateway(Configuration.instantiate())
@staticmethod
def instantiate():
return Configuration(
environment=Configuration.environment,
merchant_id=Configuration.merchant_id,
public_key=Configuration.public_key,
private_key=Configuration.private_key,
http_strategy=Configuration.default_http_strategy,
timeout=Configuration.timeout,
wrap_http_exceptions=Configuration.wrap_http_exceptions
)
@staticmethod
def api_version():
return "4"
def __init__(self, environment, merchant_id, public_key, private_key, **kwargs):
self.environment = environment
self.merchant_id = merchant_id
self.public_key = public_key
self.private_key = private_key
self.timeout = kwargs.get("timeout", 60)
self.wrap_http_exceptions = kwargs.get("wrap_http_exceptions", False)
http_strategy = kwargs.get("http_strategy", None)
if http_strategy:
self._http_strategy = http_strategy(self, self.environment)
else:
self._http_strategy = self.http()
def base_merchant_path(self):
return "/merchants/" + self.merchant_id
def base_merchant_url(self):
return self.environment.protocol + self.environment.server_and_port + self.base_merchant_path()
def http(self):
return braintree.util.http.Http(self)
def http_strategy(self):
return self._http_strategy
|