Пример #1
0
def verify_details(request):
    """
    View that handles details verification
    
    """
    if request.user.userprofile.account_level.level == 'Paid':
        error_message = "You already have a Paid account."
    if form.is_valid():
            paid_account = AccountLevel.objects.get(pk=2)
            r = authorize.call_auth(
                paid_account,
                unicode(paid_account.authnet_item_price),
                data = {
                    'card_number':form.cleaned_data['card_number'],
                    'expiry':form.cleaned_data['expiry_date'],
                    'card_code':form.cleaned_data['card_code'],
                    'first_name':form.cleaned_data['first_name'],
                    'last_name':form.cleaned_data['last_name'],
                    'company':form.cleaned_data['company'],
                    'address':form.cleaned_data['address'],
                    'city':form.cleaned_data['city'],
                    'state':form.cleaned_data['state/province'],
                    'country':form.cleaned_data['country'],
                    'zip_code':form.cleaned_data['zip_code'],
                    'email':form.cleaned_data['email'],
                    'phone':form.cleaned_data['phone']
                },
            )

    form = PaymentInformationForm(request.POST)

    context = {'form': form }
    return render(request, 'verify.html', context)
Пример #2
0
def verify_details(request):
    """
    View that handles details verification
    
    """
    if request.user.userprofile.account_level.level == 'Paid':
        error_message = "You already have a Paid account."
    if form.is_valid():
        paid_account = AccountLevel.objects.get(pk=2)
        r = authorize.call_auth(
            paid_account,
            unicode(paid_account.authnet_item_price),
            data={
                'card_number': form.cleaned_data['card_number'],
                'expiry': form.cleaned_data['expiry_date'],
                'card_code': form.cleaned_data['card_code'],
                'first_name': form.cleaned_data['first_name'],
                'last_name': form.cleaned_data['last_name'],
                'company': form.cleaned_data['company'],
                'address': form.cleaned_data['address'],
                'city': form.cleaned_data['city'],
                'state': form.cleaned_data['state/province'],
                'country': form.cleaned_data['country'],
                'zip_code': form.cleaned_data['zip_code'],
                'email': form.cleaned_data['email'],
                'phone': form.cleaned_data['phone']
            },
        )

    form = PaymentInformationForm(request.POST)

    context = {'form': form}
    return render(request, 'verify.html', context)
Пример #3
0
def upgrade_account(request):
    """
    View that handles upgrading from a Free account to a Paid account via
    Authorize.net
    
    Note: Authorize.net payment option is currently on backlog
    
    """
    error_message = ""
    success_message = ""
    if request.user.userprofile.account_level.level == 'Paid':
        error_message = "You already have a Paid account."

    if request.method == 'POST':
        form = PaymentInformationForm(request.POST)
        if form.is_valid():
            paid_account = AccountLevel.objects.get(pk=2)
            r = authorize.call_auth(
                paid_account,
                unicode(paid_account.authnet_item_price),
                data = { 
                    'card_number':form.cleaned_data['card_number'],
                    'expiry':form.cleaned_data['expiry_date'],
                    'card_code':form.cleaned_data['card_code'],
                    'first_name':form.cleaned_data['first_name'],
                    'last_name':form.cleaned_data['last_name'],
                    'company':form.cleaned_data['company'],
                    'address':form.cleaned_data['address'],
                    'city':form.cleaned_data['city'],
                    'state':form.cleaned_data['state'],
                    'province':form.cleaned_data['province'],
                    'country':form.cleaned_data['country'],
                    'zip_code':form.cleaned_data['zip_code'],
                    'email':form.cleaned_data['email'],
                    'phone':form.cleaned_data['phone']
                },
            )
            success_message = ""
            if r.split('|')[0] == '1':
                trans_id = r.split('|')[6]
                r = authorize.call_capture(trans_id)
                if r.split('|')[0] == '1':
                    error_message = ""
                    userprofile = UserProfile.objects.get(user__id=request.user.id)
                    if userprofile.account_level.level == 'Trial':
                        userprofile.trial_ended = True
                        userprofile.trial_expiry_date = None
                    userprofile.account_level = paid_account
                    api_key_len = UserProfile._meta.get_field('api_key')
                    userprofile.api_key = generate_api_key(api_key_len)
                    userprofile.save()
                    form = PaymentInformationForm(request.POST)
                    success_message = "Payment Accepted"
                    form = PaymentInformationForm(request.POST)

                    # Update user's videos expiration dates
                    vids = Video.objects.filter(uploader=request.user)
                    for vid in vids:
                        is_expired(vid)
                else:
                    error_message = r.split('|')[3]
                    form = PaymentInformationForm(request.POST)
            else:
                error_message = "%s" % (r.split('|')[3])
                form = PaymentInformationForm(request.POST)
    else:
        form = PaymentInformationForm()

    context = {
        'form': form, 
        'error_message':error_message, 
        'success_message':success_message,
    }
    return render(request, 'purchase.html', context)
Пример #4
0
def upgrade_account(request):
    """
    View that handles upgrading from a Free account to a Paid account via
    Authorize.net
    
    Note: Authorize.net payment option is currently on backlog
    
    """
    error_message = ""
    success_message = ""
    if request.user.userprofile.account_level.level == 'Paid':
        error_message = "You already have a Paid account."

    if request.method == 'POST':
        form = PaymentInformationForm(request.POST)
        if form.is_valid():
            paid_account = AccountLevel.objects.get(pk=2)
            r = authorize.call_auth(
                paid_account,
                unicode(paid_account.authnet_item_price),
                data={
                    'card_number': form.cleaned_data['card_number'],
                    'expiry': form.cleaned_data['expiry_date'],
                    'card_code': form.cleaned_data['card_code'],
                    'first_name': form.cleaned_data['first_name'],
                    'last_name': form.cleaned_data['last_name'],
                    'company': form.cleaned_data['company'],
                    'address': form.cleaned_data['address'],
                    'city': form.cleaned_data['city'],
                    'state': form.cleaned_data['state'],
                    'province': form.cleaned_data['province'],
                    'country': form.cleaned_data['country'],
                    'zip_code': form.cleaned_data['zip_code'],
                    'email': form.cleaned_data['email'],
                    'phone': form.cleaned_data['phone']
                },
            )
            success_message = ""
            if r.split('|')[0] == '1':
                trans_id = r.split('|')[6]
                r = authorize.call_capture(trans_id)
                if r.split('|')[0] == '1':
                    error_message = ""
                    userprofile = UserProfile.objects.get(
                        user__id=request.user.id)
                    if userprofile.account_level.level == 'Trial':
                        userprofile.trial_ended = True
                        userprofile.trial_expiry_date = None
                    userprofile.account_level = paid_account
                    api_key_len = UserProfile._meta.get_field('api_key')
                    userprofile.api_key = generate_api_key(api_key_len)
                    userprofile.save()
                    form = PaymentInformationForm(request.POST)
                    success_message = "Payment Accepted"
                    form = PaymentInformationForm(request.POST)

                    # Update user's videos expiration dates
                    vids = Video.objects.filter(uploader=request.user)
                    for vid in vids:
                        is_expired(vid)
                else:
                    error_message = r.split('|')[3]
                    form = PaymentInformationForm(request.POST)
            else:
                error_message = "%s" % (r.split('|')[3])
                form = PaymentInformationForm(request.POST)
    else:
        form = PaymentInformationForm()

    context = {
        'form': form,
        'error_message': error_message,
        'success_message': success_message,
    }
    return render(request, 'purchase.html', context)