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


Python api.ProviderHelper类代码示例

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


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

示例1: _callback_url

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(settings.PAYMENT_PROVIDER)

    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:Witia1,项目名称:webpay,代码行数:31,代码来源:views.py

示例2: notification

def notification(request, provider_name):
    """
    Handle server to server notification responses.
    """
    provider = ProviderHelper(provider_name)

    try:
        provider.server_notification(request)
    except msg.DevMessage as m:
        return HttpResponse(m.code, status=502)

    return HttpResponse('OK')
开发者ID:lissyx,项目名称:webpay,代码行数:12,代码来源:views.py

示例3: success

def success(request, provider_name):
    provider = ProviderHelper(provider_name)
    if provider.name != 'reference':
        raise NotImplementedError(
            'only the reference provider is implemented so far')

    try:
        transaction_id = provider.prepare_notice(request)
    except msg.DevMessage as m:
        return system_error(request, code=m.code)

    tasks.payment_notify.delay(transaction_id)
    return render(request, 'provider/success.html')
开发者ID:unghost,项目名称:webpay,代码行数:13,代码来源:views.py

示例4: notification

def notification(request, provider_name):
    """
    Handle server to server notification responses.
    """
    provider = ProviderHelper(provider_name)

    try:
        transaction_uuid = provider.server_notification(request)
    except msg.DevMessage as m:
        return HttpResponse(m.code, status=502)

    tasks.payment_notify.delay(transaction_uuid)
    return HttpResponse('OK')
开发者ID:jincreator,项目名称:webpay,代码行数:13,代码来源:views.py

示例5: _callback_url

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:jincreator,项目名称:webpay,代码行数:28,代码来源:views.py

示例6: test_from_wrong_mexican_operator

    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,代码行数:7,代码来源:tests.py

示例7: test_not_from_mexico

    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,代码行数:7,代码来源:tests.py

示例8: test_from_boku_operator

    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,代码行数:8,代码来源:tests.py

示例9: notification

def notification(request, provider_name):
    """
    Handle server to server notification responses.
    """
    provider = ProviderHelper(provider_name)

    try:
        transaction_uuid = provider.server_notification(request)
    except msg.DevMessage as m:
        return HttpResponse(m.code, status=502)

    trans = client.get_transaction(transaction_uuid)
    log.info("Processing notification for transaction {t}; status={s}".format(t=transaction_uuid, s=trans["status"]))
    if trans["status"] == STATUS_COMPLETED:
        tasks.payment_notify.delay(transaction_uuid)

    return HttpResponse("OK")
开发者ID:Joergen,项目名称:webpay,代码行数:17,代码来源:views.py

示例10: configure_transaction

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,代码行数:58,代码来源:tasks.py

示例11: success

def success(request, provider_name):
    provider = ProviderHelper(provider_name)
    if provider.name != "reference":
        raise NotImplementedError("only the reference provider is implemented so far")

    try:
        transaction_id = provider.prepare_notice(request)
    except msg.DevMessage as m:
        return system_error(request, code=m.code)

    tasks.payment_notify.delay(transaction_id)

    if settings.SPA_ENABLE:
        state, fxa_url = fxa_auth_info(request)
        ctx = {"start_view": "payment-success", "fxa_state": state, "fxa_auth_url": fxa_url}
        return render(request, "spa/index.html", ctx)

    return render(request, "provider/success.html")
开发者ID:Joergen,项目名称:webpay,代码行数:18,代码来源:views.py

示例12: error

def error(request, provider_name):
    provider = ProviderHelper(provider_name)
    if provider.name != 'reference':
        raise NotImplementedError(
            'only the reference provider is implemented so far')

    try:
        provider.prepare_notice(request)
    except msg.DevMessage as m:
        return system_error(request, code=m.code)

    # TODO: handle user cancellation, bug 957774.

    log.error('Fatal payment error for {provider}: {code}; query string: {qs}'
              .format(provider=provider.name,
                      code=request.GET.get('ResponseCode'),
                      qs=request.GET))
    return system_error(request, code=msg.EXT_ERROR)
开发者ID:JaredKerim-Mozilla,项目名称:webpay,代码行数:18,代码来源:views.py

示例13: success

def success(request, provider_name):
    provider = ProviderHelper(provider_name)
    if provider.name != 'reference':
        raise NotImplementedError(
            'only the reference provider is implemented so far')

    try:
        transaction_id = provider.prepare_notice(request)
    except msg.DevMessage as m:
        return system_error(request, code=m.code)

    tasks.payment_notify.delay(transaction_id)

    state, fxa_url = fxa_auth_info(request)
    ctx = {'start_view': 'payment-success',
           'fxa_state': state,
           'fxa_auth_url': fxa_url}
    return render(request, 'spa/index.html', ctx)
开发者ID:flodolo,项目名称:webpay,代码行数:18,代码来源:views.py

示例14: configure_transaction

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,代码行数:54,代码来源:tasks.py

示例15: success

def success(request, provider_name):
    provider = ProviderHelper(provider_name)
    if provider.name != 'reference':
        raise NotImplementedError(
            'only the reference provider is implemented so far')

    try:
        transaction_id = provider.prepare_notice(request)
    except msg.DevMessage as m:
        return system_error(request, code=m.code)

    tasks.payment_notify.delay(transaction_id)

    if settings.SPA_ENABLE:
        ctx = {'start_view': 'payment-success'}
        if settings.USE_FXA:
            ctx['fxa_state'], ctx['fxa_auth_url'] = fxa_auth_info(request)
        return render(request, 'spa/index.html', ctx)

    return render(request, 'provider/success.html')
开发者ID:Nurtas,项目名称:webpay,代码行数:20,代码来源:views.py


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