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


Python ProviderHelper.supported_providers方法代码示例

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


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

示例1: test_not_from_mexico

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

        providers = ProviderHelper.supported_providers(mcc=mcc, mnc=mnc)
        provider_names = [provider.name for provider in providers]
        eq_(provider_names, [settings.PAYMENT_PROVIDER])
开发者ID:MorrisJobke,项目名称:webpay,代码行数:9,代码来源:tests.py

示例2: test_from_wrong_mexican_operator

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

        providers = ProviderHelper.supported_providers(mcc=mcc, mnc=mnc)
        provider_names = [provider.name for provider in providers]
        eq_(provider_names, [settings.PAYMENT_PROVIDER])
开发者ID:MorrisJobke,项目名称:webpay,代码行数:9,代码来源:tests.py

示例3: test_from_boku_operator

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

        providers = ProviderHelper.supported_providers(mcc=mcc, mnc=mnc)
        provider_names = [provider.name for provider in providers]
        eq_(provider_names, [
            BokuProvider.name, settings.PAYMENT_PROVIDER])
开发者ID:MorrisJobke,项目名称:webpay,代码行数:10,代码来源:tests.py

示例4: configure_transaction

# 需要导入模块: from lib.solitude.api import ProviderHelper [as 别名]
# 或者: from lib.solitude.api.ProviderHelper import supported_providers [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", {})
    providers = ProviderHelper.supported_providers(mcc=network.get("mcc"), mnc=network.get("mnc"))

    start_pay.delay(request.session["trans_id"], request.session["notes"], request.session["uuid"], providers)

    # 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:unghost,项目名称:webpay,代码行数:56,代码来源:tasks.py

示例5: test_supported_providers_returns_default_provider

# 需要导入模块: from lib.solitude.api import ProviderHelper [as 别名]
# 或者: from lib.solitude.api.ProviderHelper import supported_providers [as 别名]
    def test_supported_providers_returns_default_provider(self):
        providers = ProviderHelper.supported_providers()
        eq_(len(providers), 1)

        provider = providers[0]
        eq_(provider.name, settings.PAYMENT_PROVIDER)
开发者ID:MorrisJobke,项目名称:webpay,代码行数:8,代码来源:tests.py

示例6: configure_transaction

# 需要导入模块: from lib.solitude.api import ProviderHelper [as 别名]
# 或者: from lib.solitude.api.ProviderHelper import supported_providers [as 别名]
def configure_transaction(request, trans=None, mcc=None, mnc=None):
    """
    Begins a background task to configure a payment transaction.

    Returns a tuple of (was_configured, error_code)

    * was_configured is a boolean
    * error_code, when not None, is an error code for the failure
    """
    if request.session.get('is_simulation', False):
        log.info('is_simulation: skipping configure payments step')
        return (False, None)

    notes = request.session.get('notes', {})
    if mcc and mnc:
        notes['network'] = {'mnc': mnc, 'mcc': mcc}
    else:
        # Reset network state to avoid leakage from previous states.
        notes['network'] = {}
    request.session['notes'] = notes
    log.info('Added mcc/mnc to session: '
             '{network}'.format(network=notes['network']))

    log.info('configuring transaction {0} from client'
             .format(request.session.get('trans_id')))

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

    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, None)

    # 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', {})
    providers = ProviderHelper.supported_providers(
        mcc=network.get('mcc'),
        mnc=network.get('mnc'),
    )

    start_pay.delay(request.session['trans_id'],
                    request.session['notes'],
                    request.session['uuid'],
                    [p.name for p in providers])

    # Now that the background task has been started successfully,
    # prevent configuration from running twice.
    request.session['configured_trans'] = request.session['trans_id']

    return (True, None)
开发者ID:flodolo,项目名称:webpay,代码行数:78,代码来源:tasks.py


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