当前位置: 首页>>代码示例>>Python>>正文


Python PayPalNVP.init方法代码示例

本文整理汇总了Python中paypal.pro.models.PayPalNVP.init方法的典型用法代码示例。如果您正苦于以下问题:Python PayPalNVP.init方法的具体用法?Python PayPalNVP.init怎么用?Python PayPalNVP.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在paypal.pro.models.PayPalNVP的用法示例。


在下文中一共展示了PayPalNVP.init方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _fetch

# 需要导入模块: from paypal.pro.models import PayPalNVP [as 别名]
# 或者: from paypal.pro.models.PayPalNVP import init [as 别名]
    def _fetch(self, params, required, defaults):
        """Make the NVP request and store the response."""
        defaults.update(params)
        pp_params = self._check_and_update_params(required, defaults)        
        pp_string = self.signature + urllib.urlencode(pp_params)
        response = self._request(pp_string)
        response_params = self._parse_response(response)
        
        print 'PayPal Request:'
        pprint.pprint(defaults)
        print '\nPayPal Response:'
        pprint.pprint(response_params)

        # Gather all NVP parameters to pass to a new instance.
        nvp_params = {}
        for k, v in MergeDict(defaults, response_params).items():
            if k in NVP_FIELDS:
                nvp_params[k] = v    

        # PayPal timestamp has to be formatted.
        if 'timestamp' in nvp_params:
            nvp_params['timestamp'] = paypaltime2datetime(nvp_params['timestamp'])

        nvp_obj = PayPalNVP(**nvp_params)
        nvp_obj.init(self.request, params, response_params)
        nvp_obj.save()
        return nvp_obj
开发者ID:alexissmirnov,项目名称:donomo,代码行数:29,代码来源:helpers.py

示例2: _fetch

# 需要导入模块: from paypal.pro.models import PayPalNVP [as 别名]
# 或者: from paypal.pro.models.PayPalNVP import init [as 别名]
    def _fetch(self, params, required, defaults):
        """Make the NVP request and store the response."""
        defaults.update(params)
        pp_params = self._check_and_update_params(required, defaults)
        pp_string = self.signature + urlencode(pp_params)
        response = self._request(pp_string)
        response_params = self._parse_response(response)

        if getattr(settings, 'PAYPAL_DEBUG', settings.DEBUG):
            log.debug('PayPal Request:\n%s\n', pprint.pformat(defaults))
            log.debug('PayPal Response:\n%s\n', pprint.pformat(response_params))

        # Gather all NVP parameters to pass to a new instance.
        nvp_params = {}
        for k, v in MergeDict(defaults, response_params).items():
            if k in NVP_FIELDS:
                nvp_params[str(k)] = v

        # PayPal timestamp has to be formatted.
        if 'timestamp' in nvp_params:
            nvp_params['timestamp'] = paypaltime2datetime(nvp_params['timestamp'])

        nvp_obj = PayPalNVP(**nvp_params)
        nvp_obj.init(self.request, params, response_params)
        nvp_obj.save()
        return nvp_obj
开发者ID:araines,项目名称:django-paypal,代码行数:28,代码来源:helpers.py

示例3: _fetch

# 需要导入模块: from paypal.pro.models import PayPalNVP [as 别名]
# 或者: from paypal.pro.models.PayPalNVP import init [as 别名]
    def _fetch(self, params, required, defaults):
        """Make the NVP request and store the response."""
        defaults.update(params)
        pp_params = self._check_and_update_params(required, defaults)
        pp_string = self.signature + urlencode(pp_params)
        response = self._request(pp_string)
        response_params = self._parse_response(response)


#        log.info( 'PayPal Request:%s\nPayPal Response:%s'%
#            (pprint.pformat(defaults),pprint.pformat(response_params)))

        # Gather all NVP parameters to pass to a new instance.
        nvp_params = {}
        for k, v in MergeDict(defaults, response_params).items():
            if k in NVP_FIELDS:
                nvp_params[str(k)] = v

        # PayPal timestamp has to be formatted.
        if 'timestamp' in nvp_params:
            nvp_params['timestamp'] = paypaltime2datetime(nvp_params['timestamp'])


        nvp_obj = PayPalNVP(**nvp_params)

        nvp_obj.init(self.request, params, response_params)
        nvp_obj.custom = params.get('PAYMENTREQUEST_0_CUSTOM','')
        nvp_obj.save()
        return nvp_obj
开发者ID:evrenesat,项目名称:ganihomes,代码行数:31,代码来源:helpers.py

示例4: _fetch

# 需要导入模块: from paypal.pro.models import PayPalNVP [as 别名]
# 或者: from paypal.pro.models.PayPalNVP import init [as 别名]
    def _fetch(self, params, required, defaults):
        """Make the NVP request and store the response."""
        defaults.update(params)
        pp_params = self._check_and_update_params(required, defaults)
        pp_string = self.signature + urlencode(pp_params)
        response = self._request(pp_string)
        response_params = self._parse_response(response)

        # save the response and request to the database:
        if 'user_email' in defaults:
            cpm = CartProcessingMessage()
            cpm.user_email_address = defaults['user_email']
            if 'firstname' in defaults:
                cpm.first_name = defaults['firstname']
            if 'lastname' in defaults:
                cpm.last_name = defaults['lastname']

            if response_params['ack'].lower() == 'failure':
                cpm.type = 'ERROR'
            else:
                cpm.type = 'SUCCESS'

            cpm.data_sent = self.clean_defaults(defaults)
            cpm.message = response_params
            cpm.save()

        if getattr(settings, 'PAYPAL_DEBUG', settings.DEBUG):
            print 'PayPal Request:'
            pprint.pprint(defaults)
            print '\nPayPal Response:'
            pprint.pprint(response_params)

        # Gather all NVP parameters to pass to a new instance.
        nvp_params = {}
        for k, v in MergeDict(defaults, response_params).items():
            if k in NVP_FIELDS:
                nvp_params[str(k)] = v

        # PayPal timestamp has to be formatted.
        if 'timestamp' in nvp_params:
            nvp_params['timestamp'] = paypaltime2datetime(nvp_params['timestamp'])

        nvp_obj = PayPalNVP(**nvp_params)
        nvp_obj.init(self.request, params, response_params)
        nvp_obj.save()
        return nvp_obj
开发者ID:jslootbeek,项目名称:django-paypal,代码行数:48,代码来源:helpers.py

示例5: _fetch

# 需要导入模块: from paypal.pro.models import PayPalNVP [as 别名]
# 或者: from paypal.pro.models.PayPalNVP import init [as 别名]
    def _fetch(
        self, params, required=None, defaults=None, extra_requirements=None):
        """Make the NVP request and store the response."""
        if required is None or defaults is None:
            assert params['METHOD'] in API_METHODS
            if required is None:
                required = API_METHODS[params['METHOD']].get('required', ())
            if defaults is None:
                defaults = API_METHODS[params['METHOD']].get('defaults', {})
        required += extra_requirements or ()
        defaults.update(params)
        pp_params = self._check_and_update_params(required, defaults)
        pp_string = self.signature + urlencode(pp_params)
        response = self._request(pp_string)
        response_params = self._parse_response(response)

        if getattr(settings, 'PAYPAL_DEBUG', settings.DEBUG):
            print 'PayPal Request:'
            pprint.pprint(defaults)
            print '\nPayPal Response:'
            pprint.pprint(response_params)

        # Gather all NVP parameters to pass to a new instance.
        nvp_params = {}

        for key, value in dict(defaults, **response_params).items():
            if key.lower() in NVP_FIELDS:
                nvp_params[str(key.lower())] = value

        # PayPal timestamp has to be formatted.
        if 'timestamp' in nvp_params:
            nvp_params['timestamp'] = paypaltime2datetime(
                nvp_params['timestamp'])

        nvp_obj = PayPalNVP(**nvp_params)
        nvp_obj.init(self.request, params, response_params)
        nvp_obj.save()
        return nvp_obj
开发者ID:FrancoisConstant,项目名称:django-paypal,代码行数:40,代码来源:helpers.py

示例6: _fetch

# 需要导入模块: from paypal.pro.models import PayPalNVP [as 别名]
# 或者: from paypal.pro.models.PayPalNVP import init [as 别名]
    def _fetch(self, params, required, defaults):
        """
        Make the NVP request and store the response.
        
        """
        # ### This function just sucks.
        
        defaults.update(params)
        pp_params = self._check_and_update_params(required, defaults)        
        pp_string = self.signature + urllib.urlencode(pp_params)
        response = urllib.urlopen(self.endpoint, pp_string).read()
        response_params = self._parse_response(response)
        
        print 'Request:'
        pprint.pprint(defaults)
        print '\nResponse:'
        pprint.pprint(response_params)

        # Put fields from NVP into everything so we can pass it to `create`.
        everything = {}
        def into_everything(d):
            for k, v in d.iteritems():
                if k in NVP_FIELDS:
                    everything[k] = v
        
        into_everything(defaults)
        into_everything(response_params)        

        if 'timestamp' in everything:
            everything['timestamp'] = paypaltime2datetime(everything['timestamp'])

        # Record this NVP.
        nvp_obj = PayPalNVP(**everything)
        nvp_obj.init(self.request, params, response_params)
        nvp_obj.save()
        return nvp_obj
开发者ID:ckelly,项目名称:django-paypal,代码行数:38,代码来源:helpers.py


注:本文中的paypal.pro.models.PayPalNVP.init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。