First, the project settings.py file add the following:
# Braintree settings BRAINTREE_MERCHANT_ID = '保密' BRAINTREE_PUBLIC_KEY = '保密' BRAINTREE_PRIVATE_KEY = '保密' from braintree import Configuration, Environment Configuration.configure( Environment.parse_environment("sandbox"), # 这一句重点,千万別写成 Environment.Sandbox # Environment.parse_environment("product"), BRAINTREE_MERCHANT_ID, BRAINTREE_PUBLIC_KEY, BRAINTREE_PRIVATE_KEY )
Two, Environment.parse_environment ( "sandbox"), the focus of this one, do not write Environment.Sandbox,
For the following reasons:
1, ctrl + left mouse button click configure the above code (parameter 1, parameter 2, parameter 3, parameter 4), one will find the parameters to fill Environment,
2, in order to find the environment,
ctrl + left mouse button click Environment code above,
Environment will find class in function def parse_environment (environment), the return value is Environment.All [environment],
正好 Environment.All["sandbox"] = Environment.Sandbox
@staticmethod def parse_environment(environment): if isinstance(environment, Environment) or environment is None: return environment try: return Environment.All[environment] # ...............................
#........................................ Environment.All = { "development": Environment.Development, "integration": Environment.Development, "qa": Environment.QA, "sandbox": Environment.Sandbox, "production": Environment.Production }