Esempio n. 1
0
def processpayment(request):
    name=request.GET['name']
    roll=request.GET['roll']
    Class=request.GET['class']
    print(Class)
    father=request.GET['father']
    ammount=request.GET['ammount']
    student=Student.objects.get(rollNo=roll)
    transaction_id=datetime.datetime.now().timestamp()
    studentfee=StudentFees.objects.create(name=name,transaction_id=transaction_id,payment=ammount,roll=roll)
    studentfee.save()
    print(student.Class)
    if not student.name==name:
        messages.error(request,'Student name does not match')
        return redirect('/payment')
    if not student.father==father:
        messages.error(request,'Student father name does not match')
        return redirect('/payment')
    param_dict={
			    
				'MID': 'toaldV34834751882298',
                'ORDER_ID': str(transaction_id),
                'TXN_AMOUNT': str(ammount),
                'CUST_ID': roll,
                'INDUSTRY_TYPE_ID': 'Retail',
                'WEBSITE': 'WEBSTAGING',
                'CHANNEL_ID': 'WEB',
                'CALLBACK_URL':'http://127.0.0.1:8000/handlerequest/',
	}
    param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(param_dict, MERCHANT_KEY)
    return render(request,'mySchool/paytm.html',{'param_dict':param_dict})		
Esempio n. 2
0
def processOrder(request):
	transaction_id = datetime.datetime.now().timestamp()
	if request.user.is_authenticated:
		customer = request.user
		email=request.POST.get('email')
		order, created = Order.objects.get_or_create(customer=customer, complete=False)
		total = order.get_cart_items
		order.transaction_id = transaction_id
		order.complete=True
		order.save()
		ShippingAddress.objects.create(
			customer=customer,
			order=order,
			address=request.POST.get('address'),
			city=request.POST.get('city'),
			state=request.POST.get('state'),
			zipcode=request.POST.get('zipcode'),
			)
		param_dict={
			    
				'MID': 'toaldV34834751882298',
                'ORDER_ID': str(transaction_id),
                'TXN_AMOUNT': str(total),
                'CUST_ID': email,
                'INDUSTRY_TYPE_ID': 'Retail',
                'WEBSITE': 'WEBSTAGING',
                'CHANNEL_ID': 'WEB',
                'CALLBACK_URL':'http://127.0.0.1:8000/handlerequest/',
		}
		param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(param_dict, MERCHANT_KEY)
		return render(request,'myapp/paytm.html',{'param_dict':param_dict})		
	else:
		print('User is not logged in')

	return redirect('')
Esempio n. 3
0
def checkout(request, course_slug):
    course = Course.objects.get(slug=course_slug)
    context = {'course': course}
    if request.method == 'POST':
        user = request.user

        # amount = request.POST.get('amount')
        amount = float(course.price)

        orderid = random.randrange(11111, 99999)
        param_dict = {
            'MID':
            'XouRsh60629205732669',
            'ORDER_ID':
            str(orderid),
            'TXN_AMOUNT':
            str(amount),
            'CUST_ID':
            user.email,
            'INDUSTRY_TYPE_ID':
            'Retail',
            'WEBSITE':
            'WEBSTAGING',
            'CHANNEL_ID':
            'WEB',
            'CALLBACK_URL':
            f'http://127.0.0.1:8000/course/handlerequest/{course_slug}/{user.username}',
        }
        param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(
            param_dict, MERCHANT_KEY)
        return render(request, 'paytm/paytm.html', {'param_dict': param_dict})

    # return render(request, 'paytm/checkout.html')

    return render(request, 'main/checkout.html', context)
Esempio n. 4
0
def buy(request):
    if request.method == "POST":
        items_json = request.POST.get('itemsJson', '')
        name = request.POST.get('name', '')
        amount = request.POST.get('amount', '')
        email = request.POST.get('email', '')
        address = request.POST.get('address1', '') + " " + request.POST.get(
            'address2', '')
        city = request.POST.get('city', '')
        state = request.POST.get('state', '')
        zip_code = request.POST.get('zip_code', '')
        phone = request.POST.get('phone', '')
        if len(zip_code) < 6:
            messages.error(request, "Please enter correct zip code")
            return redirect('Checkout')
        if len(phone) < 10:
            messages.error(request, "Please enter correct phone number")
            return redirect('Checkout')

        order = Orders(orders_json=items_json,
                       name=name,
                       email=email,
                       address=address,
                       city=city,
                       state=state,
                       zip_code=zip_code,
                       phone=phone,
                       amount=amount)
        order.save()
        update = OrderUpdate(order_id=order.order_id,
                             update_desc="The order has been placed")
        update.save()
        thank = True
        id = order.order_id
        # return render(request, 'shop/checkout.html', {'thank':thank, 'id': id})
        # Request paytm to transfer the amount to your account after payment by user
        param_dict = {
            'MID': 'Ljlxjc16845781456724',
            'ORDER_ID': str(order.order_id),
            'TXN_AMOUNT': str(amount),
            'CUST_ID': email,
            'INDUSTRY_TYPE_ID': 'Retail',
            'WEBSITE': 'WEBSTAGING',
            'CHANNEL_ID': 'WEB',
            'CALLBACK_URL': 'http://127.0.0.1:8000/shop/handlerequest2/',
        }
        param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(
            param_dict, MERCHANT_KEY)
        return render(request, 'shop/paytm.html', {'param_dict': param_dict})

    return render(request, 'shop/buynow.html')
Esempio n. 5
0
def paymentreq(request, order_id):
    msg = Rent.objects.get(id=order_id)
    #passing request to paytm
    param_dict = {
        'MID': 'WorldP64425807474247',
        'ORDER_ID': msg.order_id,
        'TXN_AMOUNT': str(msg.amount),
        'CUST_ID': str(request.user),
        'INDUSTRY_TYPE_ID': 'Retail',
        'WEBSITE': 'WEBSTAGING',
        'CHANNEL_ID': 'WEB',
        'CALLBACK_URL': 'http://18.216.172.90/handlerequest/',
    }
    param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(
        param_dict, MERCHANT_KEY)
    return render(request, 'paytm.html', {'param_dict': param_dict})
Esempio n. 6
0
def checkout(request):
    if request.method == "POST":
        items_json = request.POST.get('itemsJson', '')
        name = request.POST.get('name', '')
        amount = request.POST.get('amount', '')
        email = request.POST.get('email', '')
        address = request.POST.get('address1', '') + " " + request.POST.get(
            'address2', '')
        city = request.POST.get('city', '')
        state = request.POST.get('state', '')
        zip_code = request.POST.get('zip_code', '')
        phone = request.POST.get('phone', '')

        order = Orders(items_json=items_json,
                       name=name,
                       email=email,
                       address=address,
                       city=city,
                       state=state,
                       zip_code=zip_code,
                       phone=phone,
                       amount=amount)
        order.save()
        update = OrderUpdate(order_id=order.order_id,
                             update_desc="The order has been placed")
        update.save()

        thank = True
        id = order.order_id

        #request paytm to transfer the amount to your account after payment by user
        param_dict = {
            'MID': '',
            'ORDER_ID': str(order.order_id),
            'TXN_AMOUNT': amount,
            'CUST_ID': email,
            'INDUSTRY_TYPE_ID': 'Retail',
            'WEBSITE': 'WEBSTAGING',
            'CHANNEL_ID': 'WEB',
            'CALLBACK_URL': 'http://127.0.0.1:8080/handlerequest/',
        }
        param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(
            param_dict, MERCHANT_KEY)
        return render(request, 'paytm.html', {'param_dict': param_dict})

    return render(request, 'checkout.html')
def fee(request):
    student = Student.objects.get(user=request.user)
    c = ClassInfo.objects.get(name=student.class_info.name)
    admissionfees = 0
    monthlyfees = 0
    extrafees = 0
    if Fee.objects.filter(student=student,
                          paymentstatus="successful").count() == 0:
        admissionfees = c.admissionfees
        monthlyfees = c.monthlyfees
        extrafees = c.ExtraFees
    else:
        admissionfees = 0
        monthlyfees = c.monthlyfees
        extrafees = c.ExtraFees
    totalfees = float(monthlyfees) + float(admissionfees) + float(extrafees)

    id = None
    if request.method == "POST":
        i = Fee.objects.create(student=student, amount=totalfees)

        # return render(request, 'shop/checkout.html', {'thank':thank, 'id': id})
        # Request paytm to transfer the amount to your account after payment by user
        param_dict = {
            'MID': 'SGijGB62559210222772',
            'ORDER_ID': "school" + str(i.orderid),
            'TXN_AMOUNT': str(i.amount),
            'CUST_ID': request.user.email,
            'INDUSTRY_TYPE_ID': 'Retail',
            'WEBSITE': 'WEBSTAGING',
            'CHANNEL_ID': 'WEB',
            'CALLBACK_URL': 'http://127.0.0.1:8000/fee/handlerequest/',
        }
        param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(
            param_dict, MERCHANT_KEY)
        return render(request, 'fee/paytm.html', {'param_dict': param_dict})
    return render(
        request, 'fee/payment.html', {
            'student': student,
            'totalfees': totalfees,
            'admissionfees': admissionfees,
            'monthlyfees': monthlyfees,
            'extrafees': extrafees
        })
def checkout(request):
    if request.method == "POST":
        items_json = request.POST.get('itemsJson', '')
        name = request.POST.get('name', '')
        amount = request.POST.get('amount', '')
        email = request.POST.get('email', '')
        address = request.POST.get('address1', '') + " " + request.POST.get(
            'address2', '')
        city = request.POST.get('city', '')
        state = request.POST.get('state', '')
        zip_code = request.POST.get('zip_code', '')
        phone = request.POST.get('phone', '')
        order = Orders(items_json=items_json,
                       name=name,
                       email=email,
                       address=address,
                       city=city,
                       state=state,
                       zip_code=zip_code,
                       phone=phone,
                       amount=amount)
        order.save()

        id = order.id
        update = OrderUpdate(order_id=id,
                             update_desc="The Order has been Placed")
        update.save()
        param_dict = {
            'MID': 'xxxxxxxxxxxxxxxxxx',
            'ORDER_ID': str(order.id),
            'TXN_AMOUNT': str(amount),
            'CUST_ID': str(email),
            'MOBILE_NO': str(phone),
            'EMAIL': str(email),
            'INDUSTRY_TYPE_ID': 'Retail',
            'WEBSITE': 'WEBSTAGING',
            'CHANNEL_ID': 'WEB',
            'CALLBACK_URL': 'http://127.0.0.1:8000/handlerequest/',
        }
        param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(
            param_dict, MERCHANT_KEY)
        return render(request, 'store/paytm.html', {'param_dict': param_dict})

    return render(request, 'store/checkout.html')
Esempio n. 9
0
 def post(self, request):
     form = Checkoutform(request.POST or None)
     try:
         order_qs = Order.objects.get(user=request.user, ordered=False)
         if form.is_valid():
             Address = form.cleaned_data.get('Address')
             apartment_add = form.cleaned_data.get('apartment_add')
             country = form.cleaned_data.get('country')
             zip = form.cleaned_data.get('zip')
             #Add functionality to these fields
             #same_bill_add=form.cleaned_data.get['same_bill_add']
             #save_info=form.cleaned_data.get['save_info']
             #payment_option=form.cleaned_data.get['payment_option']
             billingaddress = BillingAddress(user=request.user,
                                             Address=Address,
                                             apartment_add=apartment_add,
                                             country=country,
                                             zip=zip)
             billingaddress.save()
             order_qs.billing = billingaddress
             order_qs.ordered = True
             order_qs.save()
             param_dict = {
                 'MID': 'MuoTsy79388780301387',
                 'ORDER_ID': str(order_qs.id + 100),
                 'TXN_AMOUNT': str(order_qs.total()),
                 'CUST_ID': request.user.username,
                 'INDUSTRY_TYPE_ID': 'Retail',
                 'WEBSITE': 'WEBSTAGING',
                 'CHANNEL_ID': 'WEB',
                 'CALLBACK_URL': 'http://127.0.0.1:8000/handlerequest/',
             }
             param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(
                 param_dict, MERCHANT_KEY)
             return render(request, 'app/paytm.html',
                           {'param_dict': param_dict})
         messages.info(request, "Failed checkout")
         return redirect("app:checkout")
     except ObjectDoesNotExist:
         messages.info(request, "You do not have any active order")
         return redirect("app:order")
Esempio n. 10
0
def publish(request, ad_id, screen_id):
    ad = None

    screen = None

    for ads in AdMedia.objects.all():
        print(ads.id)
        if ads.id == int(ad_id):
            ad = ads
            break
    for screens in Screens.objects.all():
        if screens.auto_id == int(screen_id):
            screen = screens
            break
    print(1, screen)
    print(2, ad)
    if not screen or not ad or ad.username != request.user:
        # Screen or Ad not found.
        # Advertisement does not belong to the current user.
        # Or Screen is occupied fully.
        return redirect('/adv/publish/' + str(ad_id) +
                        '?info=Some Error Occurred&msgtype=error')
    if screen.ad_available <= 0:
        return redirect('/adv/publish/' + str(ad_id) +
                        '?info=Screen not available&msgtype=warning')

    for x in range(10):
        # print 10 random values between
        # 1 and 100 which are multiple of 5
        ra = ''.join([
            random.choice(string.ascii_letters + string.digits)
            for n in range(15)
        ])

    print(screen_id)
    cost = get_cost_inner(screen.auto_id)
    sub_obj = Subscription(gateway_id=str(ra), screen=screen, ad=ad, cost=cost)
    sub_obj.save()
    print('subcription_id', sub_obj.transaction_id)
    param_dict = {
        'MID':
        'BiDzIl44175596745392',
        'ORDER_ID':
        str(ra),
        'TXN_AMOUNT':
        str(cost),
        'CUST_ID':
        str(screen_id),
        'INDUSTRY_TYPE_ID':
        'Retail',
        'WEBSITE':
        'WEBSTAGING',
        'CHANNEL_ID':
        'WEB',
        'CALLBACK_URL':
        'http://127.0.0.1:8000/adv/handlerequest/' +
        str(sub_obj.transaction_id),
    }

    param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(
        param_dict, MERCHANT_KEY)

    return render(request, 'Advertiser/paytm.html', {'param_dict': param_dict})