예제 #1
0
def paypal_shortcut(user, subscription):
    try:
        us = user.usersubscription_set.get(active=True)
    except UserSubscription.DoesNotExist:
        change_denied_reasons = None
        us = None
    else:
        change_denied_reasons = us.try_change(subscription)

    if change_denied_reasons:
        form = None
    else:
        form = _paypal_form(subscription,
                            user,
                            upgrade_subscription=(us is not None)
                            and (us.subscription != subscription))

    current_plan_price = 0

    if us is not None:
        current_plan_price = us.subscription.price

    return {
        'form': form,
        'change_denied_reasons': change_denied_reasons,
        'test': settings.PAYPAL_TEST,
        'subscription': subscription,
        'current_plan_price': current_plan_price,
        'current': us and (subscription == us.subscription) and us,
        'cancel_url': cancel_url,
        'image_url':
        "https://www.paypal.com/en_US/i/btn/btn_unsubscribe_LG.gif"
    }
def paypal_shortcut(user, subscription):
    try:
        us = user.usersubscription_set.get(
            active=True)
    except UserSubscription.DoesNotExist:
        change_denied_reasons = None
        us = None
    else:
        change_denied_reasons = us.try_change(subscription)

    if change_denied_reasons:
        form = None
    else:
        form = _paypal_form(subscription, user,
                    upgrade_subscription=(us is not None) and (us.subscription != subscription))

    current_plan_price = 0

    if us is not None:
        current_plan_price = us.subscription.price


    return {'form': form, 'change_denied_reasons': change_denied_reasons,
            'test': settings.PAYPAL_TEST,
            'subscription': subscription,
            'current_plan_price': current_plan_price,
            'current': us and (subscription == us.subscription) and us, 'cancel_url': cancel_url,
            'image_url': "https://www.paypal.com/en_US/i/btn/btn_unsubscribe_LG.gif"} 
    
예제 #3
0
def store(request, extra_context=None):
    subscriptions = Subscription.objects.get(id=1)
    form_class = EmailRegistrationForm
    form = form_class()

    genericUser = get_object_or_404(User, id=1)
    endpoint = (SANDBOX_POSTBACK_ENDPOINT if settings.PAYPAL_TEST else POSTBACK_ENDPOINT)

    student_dict = {
        'cmd': '_cart',
        "business": settings.PAYPAL_RECEIVER_EMAIL,
        "discount_rate_cart": '0',
        "invoice": genInvoiceID('C'),
        "payer_email": '',
        "notify_url": "%s%s" % (settings.SITE_NAME, reverse('paypal-ipn')),
        "return_url": "%s%s" % (settings.SITE_NAME, '/thanks/'),
        "cancel_return": "%s%s" % (settings.SITE_NAME, '/cancel/'),
    }

    # Create the instances.
    student = PayPalPaymentsForm(initial=student_dict, button_class="pull-right btn-danger", button_text="Select your Lectures", button_type="bootstrap")
    subscription = _paypal_form(get_object_or_404(Subscription, id=1), genericUser, upgrade_subscription=False, invoice=genInvoiceID('L'))
    subscriptionForm = mark_safe(PAYPAL_FORM % (endpoint, subscription.as_p()))

    context = dict(
        lecture_list=Lecture.objects.all(),
        subscription=subscriptions,
        student=student,
        form=form,
        subscription_form=subscriptionForm,
    )
    
    if extra_context is None:
        extra_context = {}
    for key, value in extra_context.items():
        context[key] = callable(value) and value() or value
    
    return render(request, 'base/store.html', context)
예제 #4
0
def license(request):
    subscriptions = Subscription.objects.get(id=1)
    form_class = EmailRegistrationForm
    form = form_class()

    genericUser = get_object_or_404(User, id=1)
    endpoint = (SANDBOX_POSTBACK_ENDPOINT if settings.PAYPAL_TEST else POSTBACK_ENDPOINT)

    # Create the instances.
    subscription = _paypal_form(get_object_or_404(Subscription, id=1), genericUser, upgrade_subscription=False, invoice=genInvoiceID('L'))
    subscriptionForm = mark_safe(PAYPAL_FORM % (endpoint, subscription.as_p()))

    lectures = Lecture.objects.all().order_by('poem__poet__last_name')
    for lecture in lectures:
        lecture.poem.poet.slug = lecture.poem.poet.last_name.lower()

    context = dict(
        lecture_list=lectures,
        subscription=subscriptions,
        form=form,
        subscription_form=subscriptionForm,
    )
    
    return render(request, 'base/license.html', context)