'PayPalConfig constructor. **kwargs catches all of the user-specified
config directives at time of instantiation. It is fine to set these
values post-instantiation, too.
Some basic validation for a few values is performed below, and defaults
are applied for certain directives in the absence of
user-provided values.'

def __init__(self, **kwargs):

    if kwargs.get('API_ENVIRONMENT'):
        api_environment = kwargs['API_ENVIRONMENT'].upper()
        if (api_environment not in self._valid_['API_ENVIRONMENT']):
            raise PayPalConfigError('Invalid    API_ENVIRONMENT')
        else:
            self.API_ENVIRONMENT = api_environment
    if kwargs.get('API_AUTHENTICATION_MODE'):
        auth_mode = kwargs['API_AUTHENTICATION_MODE'].upper()
        if (auth_mode not in self._valid_['API_AUTHENTICATION_MODE']):
            choices = ',    '.join(self._valid_['API_AUTHENTICATION_MODE'])
            raise PayPalConfigError(('Not    a    supported    auth    mode.    Use    one    of:    %s' % choices))
        else:
            self.API_AUTHENTICATION_MODE = auth_mode
    self.API_ENDPOINT = self._API_ENDPOINTS[self.API_AUTHENTICATION_MODE][self.API_ENVIRONMENT]
    self.PAYPAL_URL_BASE = self._PAYPAL_URL_BASE[self.API_ENVIRONMENT]
    if ('API_CA_CERTS' in kwargs):
        self.API_CA_CERTS = kwargs['API_CA_CERTS']
        if (isinstance(self.API_CA_CERTS, basestring) and (not os.path.exists(self.API_CA_CERTS))):
            raise PayPalConfigError('Invalid    API_CA_CERTS')
    if (self.API_AUTHENTICATION_MODE in ('3TOKEN', 'CERTIFICATE')):
        auth_args = ['API_USERNAME', 'API_PASSWORD']
        if (self.API_AUTHENTICATION_MODE == '3TOKEN'):
            auth_args.append('API_SIGNATURE')
        elif (self.API_AUTHENTICATION_MODE == 'CERTIFICATE'):
            auth_args.extend(['API_CERTIFICATE_FILENAME', 'API_KEY_FILENAME'])
        for arg in auth_args:
            if (arg not in kwargs):
                raise PayPalConfigError(('Missing    in    PayPalConfig:    %s    ' % arg))
            setattr(self, arg, kwargs[arg])
    for arg in ['HTTP_TIMEOUT']:
        if (arg in kwargs):
            setattr(self, arg, kwargs[arg])
    logger.debug(('PayPalConfig    object    instantiated    with    kwargs:    %s' % pformat(kwargs)))
