コード例 #1
0
ファイル: views.py プロジェクト: Joergen/webpay
def wait_to_finish(request, provider_name):
    """
    After the payment provider finishes the pay flow, wait for completion.

    The provider redirects here so the UI can poll Solitude until the
    transaction is complete.
    """
    helper = ProviderHelper(provider_name)
    trans_uuid = helper.provider.transaction_from_notice(request.GET)
    if not trans_uuid:
        # This could happen if someone is tampering with the URL or if
        # the payment provider changed their URL parameters.
        log.info(
            "no transaction found for provider {p}; url: {u}".format(p=helper.provider.name, u=request.get_full_path())
        )
        return HttpResponseNotFound()

    trans_url = reverse("provider.transaction_status", args=[trans_uuid])

    if settings.SPA_ENABLE:
        state, fxa_url = fxa_auth_info(request)
        ctx = {
            "transaction_status_url": trans_url,
            "start_view": "wait-to-finish",
            "fxa_state": state,
            "fxa_auth_url": fxa_url,
        }

        return render(request, "spa/index.html", ctx)

    return render(request, "provider/wait-to-finish.html", {"transaction_status_url": trans_url})
コード例 #2
0
ファイル: views.py プロジェクト: Witia1/webpay
def index(request, view_name=None, start_view=None):
    """Page that serves the static Single Page App (Spartacus)."""
    if not settings.SPA_ENABLE:
        return http.HttpResponseForbidden()
    ctx = {}
    ctx['fxa_state'], ctx['fxa_auth_url'] = fxa_auth_info(request)
    jwt = request.GET.get('req')

    if jwt:
        ctx['mkt_user'] = False

    # If this is a Marketplace-issued JWT, verify its signature and skip login
    # for the purchaser named in it.
    if jwt and _get_issuer(jwt) == settings.KEY:
        try:
            data = verify_sig(jwt, settings.SECRET)
            data = data['request'].get('productData', '')
        except InvalidJWT:
            pass
        else:
            product_data = urlparse.parse_qs(data)
            emails = product_data.get('buyer_email')
            if emails:
                log.info("Creating session for marketplace user " +
                         str(emails))
                set_user(request, emails[0], verified=False)
                ctx['mkt_user'] = True

    # This has to come after set_user as set_user modifies the session.
    ctx['super_powers'] = request.session.get('super_powers', False)
    return render(request, 'spa/index.html', ctx)
コード例 #3
0
def index(request, view_name=None, start_view=None):
    """Page that serves the static Single Page App (Spartacus)."""
    ctx = {}
    ctx['fxa_state'], ctx['fxa_auth_url'] = fxa_auth_info(request)
    jwt = request.GET.get('req')

    if jwt:
        ctx['mkt_user'] = False

    # If this is a Marketplace-issued JWT, verify its signature and skip login
    # for the purchaser named in it.
    if jwt and _get_issuer(jwt) == settings.KEY:
        try:
            data = verify_sig(jwt,
                              settings.SECRET,
                              expected_aud=settings.DOMAIN)
            data = data['request'].get('productData', '')
        except InvalidJWT, exc:
            log.debug(
                'ignoring invalid Marketplace JWT error: {e}'.format(e=exc))
        else:
            product_data = urlparse.parse_qs(data)
            emails = product_data.get('buyer_email')
            if emails:
                log.info("Creating session for marketplace user " +
                         str(emails))
                set_user(request, emails[0], verified=False)
                ctx['mkt_user'] = True
コード例 #4
0
ファイル: views.py プロジェクト: flodolo/webpay
def index(request, view_name=None, start_view=None):
    """Page that serves the static Single Page App (Spartacus)."""
    ctx = {}
    ctx['fxa_state'], ctx['fxa_auth_url'] = fxa_auth_info(request)
    jwt = request.GET.get('req')

    if jwt:
        ctx['mkt_user'] = False

    # If this is a Marketplace-issued JWT, verify its signature and skip login
    # for the purchaser named in it.
    if jwt and _get_issuer(jwt) == settings.KEY:
        try:
            data = verify_sig(jwt, settings.SECRET,
                              expected_aud=settings.DOMAIN)
            data = data['request'].get('productData', '')
        except InvalidJWT, exc:
            log.debug('ignoring invalid Marketplace JWT error: {e}'
                      .format(e=exc))
        else:
            product_data = urlparse.parse_qs(data)
            emails = product_data.get('buyer_email')
            if emails:
                log.info("Creating session for marketplace user " +
                         str(emails))
                set_user(request, emails[0], verified=False)
                ctx['mkt_user'] = True
コード例 #5
0
ファイル: views.py プロジェクト: Nurtas/webpay
def wait_to_finish(request, provider_name):
    """
    After the payment provider finishes the pay flow, wait for completion.

    The provider redirects here so the UI can poll Solitude until the
    transaction is complete.
    """
    helper = ProviderHelper(provider_name)
    trans_uuid = helper.provider.transaction_from_notice(request.GET)
    if not trans_uuid:
        # This could happen if someone is tampering with the URL or if
        # the payment provider changed their URL parameters.
        log.info('no transaction found for provider {p}; url: {u}'
                 .format(p=helper.provider.name, u=request.get_full_path()))
        return HttpResponseNotFound()

    trans_url = reverse('provider.transaction_status', args=[trans_uuid])

    if settings.SPA_ENABLE:
        ctx = {
            'transaction_status_url': trans_url,
            'start_view': 'wait-to-finish'
        }
        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/wait-to-finish.html',
                  {'transaction_status_url': trans_url})
コード例 #6
0
def custom_error(request, user_message, code=msg.UNEXPECTED_ERROR, status=400):
    from webpay.base.helpers import fxa_auth_info
    error = {'error': user_message, 'error_code': code}
    if 'application/json' in request.META.get('HTTP_ACCEPT', ''):
        return HttpResponse(
            content=json.dumps(error),
            content_type='application/json; charset=utf-8',
            status=status)

    state, fxa_url = fxa_auth_info(request)
    ctx = {'start_view': 'payment-failed',
           'error_code': code,
           'fxa_state': state,
           'fxa_auth_url': fxa_url}
    return render(request, 'spa/index.html', ctx, status=status)
コード例 #7
0
ファイル: views.py プロジェクト: Joergen/webpay
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")
コード例 #8
0
ファイル: views.py プロジェクト: flodolo/webpay
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)
コード例 #9
0
ファイル: utils.py プロジェクト: Nurtas/webpay
def custom_error(request, user_message, code=None, status=400):
    error = {'error': user_message, 'error_code': code}
    if 'application/json' in request.META.get('HTTP_ACCEPT', ''):
        return HttpResponse(
            content=json.dumps(error),
            content_type='application/json; charset=utf-8',
            status=status)

    if settings.SPA_ENABLE:
        ctx = {'start_view': 'payment-failed',
               'error_code': code}

        if settings.USE_FXA:
            # Avoid circular import.
            from webpay.base.helpers import fxa_auth_info
            ctx['fxa_state'], ctx['fxa_auth_url'] = fxa_auth_info(request)

        return render(request, 'spa/index.html', ctx, status=status)

    return render(request, 'error.html', error, status=status)
コード例 #10
0
ファイル: views.py プロジェクト: Nurtas/webpay
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')
コード例 #11
0
ファイル: views.py プロジェクト: Joergen/webpay
def success(request):
    """
    Process a redirect request after the Bango payment has completed.
    This URL endpoint is pre-arranged with Bango via the Billing Config API.

    Example request:

    ?ResponseCode=OK&ResponseMessage=Success&BangoUserId=1473894939
    &MerchantTransactionId=webpay%3a14d6a53c-fc4c-4bd1-8dc0-9f24646064b8
    &BangoTransactionId=1078692145
    &TransactionMethods=USA_TMOBILE%2cT-Mobile+USA%2cTESTPAY%2cTest+Pay
    &BillingConfigurationId=218240
    &MozSignature=
    c2cf7b937720c6e41f8b6401696cf7aef56975ebe54f8cee51eff4eb317841af
    &Currency=USD&Network=USA_TMOBILE&Price=0.99&P=
    """
    log.info('Bango success: %s' % request.GET)

    # We should only have OK's coming from Bango, presumably.
    if request.GET.get('ResponseCode') != 'OK':
        log.error('in success(): Invalid Bango response code: {code}'
                  .format(code=request.GET.get('ResponseCode')))
        return system_error(request, code=msg.BAD_BANGO_CODE)

    result = _record(request)
    if result is not RECORDED_OK:
        return system_error(request, code=result)

    # Signature verification was successful; fulfill the payment.
    tasks.payment_notify.delay(request.GET.get('MerchantTransactionId'))

    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, 'bango/success.html')
コード例 #12
0
def success(request):
    """
    Process a redirect request after the Bango payment has completed.
    This URL endpoint is pre-arranged with Bango via the Billing Config API.

    Example request:

    ?ResponseCode=OK&ResponseMessage=Success&BangoUserId=1473894939
    &MerchantTransactionId=webpay%3a14d6a53c-fc4c-4bd1-8dc0-9f24646064b8
    &BangoTransactionId=1078692145
    &TransactionMethods=USA_TMOBILE%2cT-Mobile+USA%2cTESTPAY%2cTest+Pay
    &BillingConfigurationId=218240
    &MozSignature=
    c2cf7b937720c6e41f8b6401696cf7aef56975ebe54f8cee51eff4eb317841af
    &Currency=USD&Network=USA_TMOBILE&Price=0.99&P=
    """
    log.info('Bango success: %s' % request.GET)

    # We should only have OK's coming from Bango, presumably.
    if request.GET.get('ResponseCode') != 'OK':
        log.error('in success(): Invalid Bango response code: {code}'
                  .format(code=request.GET.get('ResponseCode')))
        return system_error(request, code=msg.BAD_BANGO_CODE)

    result = _record(request)
    if result is not RECORDED_OK:
        return system_error(request, code=result)

    # Signature verification was successful; fulfill the payment.
    tasks.payment_notify.delay(request.GET.get('MerchantTransactionId'))

    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)