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


Python ProviderHelper.choose方法代码示例

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


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

示例1: _callback_url

# 需要导入模块: from lib.solitude.api import ProviderHelper [as 别名]
# 或者: from lib.solitude.api.ProviderHelper import choose [as 别名]
def _callback_url(request, is_success):
    status = is_success and 'success' or 'error'
    signed_notice = request.POST['signed_notice']
    statsd.incr('purchase.payment_{0}_callback.received'.format(status))

    # This is currently only used by Bango and Zippy.
    # Future providers should probably get added to the notification
    # abstraction in provider/views.py
    provider = ProviderHelper.choose()

    if provider.is_callback_token_valid(signed_notice):
        statsd.incr('purchase.payment_{0}_callback.ok'.format(status))
        log.info('Callback {0} token was valid.'.format(status))
        querystring = http.QueryDict(signed_notice)
        if 'ext_transaction_id' in querystring:
            ext_transaction_id = querystring['ext_transaction_id']
            if is_success:
                tasks.payment_notify.delay(ext_transaction_id)
            else:
                tasks.chargeback_notify.delay(ext_transaction_id)
            return http.HttpResponse(status=204)
        else:
            statsd.incr('purchase.payment_{0}_callback.incomplete'
                        ''.format(status))
            log.error('Callback {0} token was incomplete: '
                      '{1}'.format(status, querystring))
    else:
        statsd.incr('purchase.payment_{0}_callback.fail'.format(status))
        log.error('Callback {0} token was invalid: '
                  '{1}'.format(status, signed_notice))
    return http.HttpResponseBadRequest()
开发者ID:oremj,项目名称:webpay,代码行数:33,代码来源:views.py

示例2: configure_transaction

# 需要导入模块: from lib.solitude.api import ProviderHelper [as 别名]
# 或者: from lib.solitude.api.ProviderHelper import choose [as 别名]
def configure_transaction(request, trans=None):
    """
    Begins a background task to configure a payment transaction.
    """
    if request.session.get('is_simulation', False):
        log.info('is_simulation: skipping configure payments step')
        return False

    if not trans and not 'trans_id' in request.session:
        log.error('trans_id: not found in session')
        return False

    try:
        if not trans:
            trans = client.get_transaction(uuid=request.session['trans_id'])
        log.info('attempt to reconfigure trans {0} (status={1})'
                 .format(request.session['trans_id'], trans['status']))
    except ObjectDoesNotExist:
        trans = {}

    if trans.get('status') in constants.STATUS_RETRY_OK:
        new_trans_id = trans_id()
        log.info('retrying trans {0} (status={1}) as {2}'
                 .format(request.session['trans_id'],
                         trans['status'], new_trans_id))
        request.session['trans_id'] = new_trans_id

    last_configured = request.session.get('configured_trans')
    if last_configured == request.session['trans_id']:
        log.info('trans %s (status=%r) already configured: '
                 'skipping configure payments step'
                 % (request.session['trans_id'], trans.get('status')))
        return False

    # Prevent configuration from running twice.
    request.session['configured_trans'] = request.session['trans_id']

    # Localize the product before sending it off to solitude/bango.
    _localize_pay_request(request)

    log.info('configuring payment in background for trans {t} (status={s}); '
             'Last configured: {c}'.format(t=request.session['trans_id'],
                                           s=trans.get('status'),
                                           c=last_configured))

    network = request.session['notes'].get('network', {})
    provider = ProviderHelper.choose(mcc=network.get('mcc'),
                                     mnc=network.get('mnc'))

    start_pay.delay(request.session['trans_id'],
                    request.session['notes'],
                    request.session['uuid'],
                    provider.name)

    # We passed notes to start_pay (which saves it to the transaction
    # object), so delete it from the session to save cookie space.
    del request.session['notes']
    return True
开发者ID:jincreator,项目名称:webpay,代码行数:60,代码来源:tasks.py

示例3: test_no_network

# 需要导入模块: from lib.solitude.api import ProviderHelper [as 别名]
# 或者: from lib.solitude.api.ProviderHelper import choose [as 别名]
 def test_no_network(self):
     provider = ProviderHelper.choose()
     eq_(provider.name, BangoProvider.name)
开发者ID:jincreator,项目名称:webpay,代码行数:5,代码来源:tests.py

示例4: test_not_from_mexico

# 需要导入模块: from lib.solitude.api import ProviderHelper [as 别名]
# 或者: from lib.solitude.api.ProviderHelper import choose [as 别名]
    def test_not_from_mexico(self):
        mcc = '214'  # Spain
        mnc = '01'  # Vodaphone

        provider = ProviderHelper.choose(mcc=mcc, mnc=mnc)
        eq_(provider.name, BangoProvider.name)
开发者ID:jincreator,项目名称:webpay,代码行数:8,代码来源:tests.py

示例5: test_from_wrong_mexican_operator

# 需要导入模块: from lib.solitude.api import ProviderHelper [as 别名]
# 或者: from lib.solitude.api.ProviderHelper import choose [as 别名]
    def test_from_wrong_mexican_operator(self):
        mcc = '334'  # Mexico
        mnc = '03'  # Movistar

        provider = ProviderHelper.choose(mcc=mcc, mnc=mnc)
        eq_(provider.name, BangoProvider.name)
开发者ID:jincreator,项目名称:webpay,代码行数:8,代码来源:tests.py

示例6: test_from_boku_operator

# 需要导入模块: from lib.solitude.api import ProviderHelper [as 别名]
# 或者: from lib.solitude.api.ProviderHelper import choose [as 别名]
    def test_from_boku_operator(self):
        mcc = '334'  # Mexico
        mnc = '020'  # AMX

        provider = ProviderHelper.choose(mcc=mcc, mnc=mnc)
        eq_(provider.name, BokuProvider.name)
开发者ID:jincreator,项目名称:webpay,代码行数:8,代码来源:tests.py


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