Example #1
0
def subscriptions_login(req):
    email = req.GET.get('email', req.POST.get('email'))
    if req.GET.get(CONFIRMATION_PARAM):
        validated = validate_confirmation(req)
        if validated:
            try:
                tip_user = TipUser.objects.get(email_address=email)
            except TipUser.DoesNotExist:
                # Verified because they just confirmed their email
                tip_user = TipUser(email=email, verified=True)
                tip_user.save()

            req.session['pay_session'] = tip_user.id
            return redirect('tip_jar_subs')
        # fallthrough

    if not req.POST:
        return _pmrender(req, 'payments/tip_jar/login.html')

    send_email(
        req.POST.get('email'),
        ugettext('Podcast Tip Jar - Email Verification'),
        ugettext(
            'Thanks for verifying your email! Click the link below '
            'to see your podcast subscriptions.'),
        reverse('tip_jar_login') + '?email=%s' % quote(email))

    return _pmrender(req, 'payments/tip_jar/check_email.html')
Example #2
0
def subscriptions_login(req):
    email = req.GET.get('email', req.POST.get('email'))
    if req.GET.get(CONFIRMATION_PARAM):
        validated = validate_confirmation(req)
        if validated:
            try:
                tip_user = TipUser.objects.get(email_address=email)
            except TipUser.DoesNotExist:
                # Verified because they just confirmed their email
                tip_user = TipUser(email=email, verified=True)
                tip_user.save()

            req.session['pay_session'] = tip_user.id
            return redirect('tip_jar_subs')
        # fallthrough

    if not req.POST:
        return _pmrender(req, 'payments/tip_jar/login.html')

    send_email(
        req.POST.get('email'),
        ugettext('Podcast Tip Jar - Email Verification'),
        ugettext(
            'Thanks for verifying your email! Click the link below '
            'to see your podcast subscriptions.'),
        reverse('tip_jar_login') + '?email=%s' % quote(email))

    return _pmrender(req, 'payments/tip_jar/check_email.html')
Example #3
0
def _auth_subscription(req, podcast, amount):
    email = req.POST.get('email')
    token = req.POST.get('token')

    if not email:
        return {'error': ugettext('No valid email address was found.')}

    # Create the tip user if it doesn't already exist
    tipper = TipUser.tip_user_from(email_address=email)

    if tipper.id == req.session.get('pay_session'):
        try:
            _finish_sub(req, podcast, amount, email, token)
            return {'success': True, 'status': 'complete'}
        except Exception as e:
            pass

    send_email(
        email,
        ugettext('Confirm your subscription for %s') % podcast.name,
        ugettext(
            'Thanks for pledging your support for %s at $%0.2f every month! '
            'To finish the process and activate your subscription, click the '
            'link below. The link in this email will expire after one day.\n\n'
            'If you did not request this, you can ignore this email.' %
            (podcast.name, float(amount) / 100)),
        reverse('tip_jar_confirm_sub', podcast_slug=podcast.slug) +
        '?email=%s&token=%s&amount=%d' % (quote(email), quote(token), amount))

    return {'success': True, 'status': 'pending'}
Example #4
0
def _auth_subscription(req, podcast, amount):
    email = req.POST.get('email')
    token = req.POST.get('token')

    if not email:
        return {'error': ugettext('No valid email address was found.')}

    # Create the tip user if it doesn't already exist
    tipper = TipUser.tip_user_from(email_address=email)

    if tipper.id == req.session.get('pay_session'):
        try:
            _finish_sub(req, podcast, amount, email, token)
            return {'success': True, 'status': 'complete'}
        except Exception as e:
            pass

    send_email(
        email,
        ugettext('Confirm your subscription for %s') % podcast.name,
        ugettext(
            'Thanks for pledging your support for %s at $%0.2f every month! '
            'To finish the process and activate your subscription, click the '
            'link below. The link in this email will expire after one day.\n\n'
            'If you did not request this, you can ignore this email.' %
            (podcast.name, float(amount) / 100)),
        reverse('tip_jar_confirm_sub', podcast_slug=podcast.slug) +
        '?email=%s&token=%s&amount=%d' % (quote(email), quote(token), amount))

    return {'success': True, 'status': 'pending'}