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


Python PaymentProcessor.get_gateway_url方法代码示例

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


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

示例1: PaymentProcessorGetGatewayUrl

# 需要导入模块: from getpaid.backends.transferuj import PaymentProcessor [as 别名]
# 或者: from getpaid.backends.transferuj.PaymentProcessor import get_gateway_url [as 别名]
class PaymentProcessorGetGatewayUrl(TestCase):

    def setUp(self):
        self.payment = PaymentFactory()
        self.pp = PaymentProcessor(self.payment)

    def update_settings(self, data):
        settings = get_backend_settings('getpaid.backends.transferuj')
        settings.update(data)

        return {'getpaid.backends.transferuj': settings}

    def get_geteway_data(self):
        settings = self.update_settings({'method': 'post'})
        with self.settings(GETPAID_BACKENDS_SETTINGS=settings):
            url, method, data = self.pp.get_gateway_url(Mock())

        return data

    def test_return_types(self):
        settings = self.update_settings({'method': 'get'})

        with self.settings(GETPAID_BACKENDS_SETTINGS=settings):
            url, method, data = self.pp.get_gateway_url(Mock())

        self.assertEquals(method, 'GET')
        self.assertEquals(data, {})
        self.assertIsInstance(url, str)

    def test_default_config_url_transaction_params(self):
        data = self.get_geteway_data()

        crc = data['crc']
        kwota = data['kwota']
        id_ = data['id']
        key = PaymentProcessor.get_backend_setting('key')
        md5sum = six.text_type(id_) + kwota + six.text_type(crc) + key
        md5sum = md5sum.encode('utf-8')

        self.assertEquals(crc, self.payment.pk)
        self.assertEquals(kwota, six.text_type(self.payment.amount))
        self.assertEquals(id_, 1234)
        self.assertEquals(data['md5sum'], md5(md5sum).hexdigest())

    def test_default_config_url_data_params(self):
        data = self.get_geteway_data()

        self.assertEquals(data['email'], '[email protected]')
        self.assertIn('opis', data)
        self.assertNotIn('jezyk', data)

    def get_urls(self):
        return {
            'wyn_url': reverse('getpaid:transferuj:online'),
            'pow_url_blad': reverse('getpaid:transferuj:failure',
                                    kwargs={'pk': self.payment.pk}),
            'pow_url': reverse('getpaid:transferuj:success',
                               kwargs={'pk': self.payment.pk}),
        }

    def test_default_config_url_urls(self):
        data = self.get_geteway_data()

        for key, u in self.get_urls().items():
            str_ = data[key]
            self.assertTrue(str_.endswith(u),
                            "{} not end with {}".format(str_, u))

    @patch.object(transferuj, 'get_domain')
    def test_domains_http(self, patch_domain):
        patch_domain.return_value = 'test'

        data = self.get_geteway_data()

        for key in self.get_urls():
            self.assertTrue(data[key].startswith('http://test/'))

    @patch.object(transferuj, 'get_domain')
    def test_domains_https(self, patch_domain):
        patch_domain.return_value = 'test'
        settings = self.update_settings({
            'force_ssl_online': True,
            'force_ssl_return': True,
        })

        with self.settings(GETPAID_BACKENDS_SETTINGS=settings):
            data = self.get_geteway_data()

        for key in self.get_urls():
            str_ = data[key]
            self.assertTrue(str_.startswith('https://test/'),
                            "{} not start with https://test/".format(str_))

    def test_post(self):
        settings = self.update_settings({'method': 'post'})

        with self.settings(GETPAID_BACKENDS_SETTINGS=settings):
            url, method, data = self.pp.get_gateway_url(Mock())

        self.assertEquals(method, 'POST')
#.........这里部分代码省略.........
开发者ID:dcondeurra,项目名称:django-getpaid,代码行数:103,代码来源:test_transferuj.py


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