Example #1
0
def payment(request):
    saved_address = BillingAddress.objects.get_or_create(user=request.user)
    saved_address = saved_address[0]
    if not saved_address.is_fully_filled():
        messages.info(request, f"Please complete shipping address!")
        return redirect("App_Payment:checkout")

    if not request.user.profile.is_fully_filled():
        messages.info(request, f"Please complete profile details!")
        return redirect("App_Login:profile")

    store_id = 'abc6017fa24c88a8'
    API_key = 'abc6017fa24c88a8@ssl'
    mypayment = SSLCSession(sslc_is_sandbox=True, sslc_store_id=store_id, sslc_store_pass=API_key)

    status_url = request.build_absolute_uri(reverse("App_Payment:complete"))
    #print(status_url)
    mypayment.set_urls(success_url=status_url, fail_url=status_url, cancel_url=status_url, ipn_url=status_url)

    order_qs = Order.objects.filter(user=request.user, ordered=False)
    order_items = order_qs[0].orderitems.all()
    order_items_count = order_qs[0].orderitems.count()
    order_total = order_qs[0].get_totals()

    mypayment.set_product_integration(total_amount=Decimal(order_total), currency='BDT', product_category='Mixed', product_name=order_items, num_of_item=order_items_count, shipping_method='Courier', product_profile='None')


    current_user = request.user
    mypayment.set_customer_info(name=current_user.profile.full_name, email=current_user.email, address1=current_user.profile.address_1, address2=current_user.profile.address_1, city=current_user.profile.city, postcode=current_user.profile.zipcode, country=current_user.profile.country, phone=current_user.profile.phone)

    mypayment.set_shipping_info(shipping_to=current_user.profile.full_name, address=saved_address.address, city=saved_address.city, postcode=saved_address.zipcode, country=saved_address.country)

    response_data = mypayment.init_payment()
    return redirect(response_data['GatewayPageURL'])
Example #2
0
def paymentRequest(request):
    #print(request.user.email)

    mypayment = SSLCSession(sslc_is_sandbox=True,
                            sslc_store_id=settings.STORE_ID,
                            sslc_store_pass=settings.STORE_PASSWORD)

    url_status = request.build_absolute_uri(reverse("payment_complete"))

    mypayment.set_urls(success_url=url_status,
                       fail_url=url_status,
                       cancel_url=url_status,
                       ipn_url=url_status)

    mypayment.set_product_integration(total_amount=Decimal('39.00'),
                                      currency='BDT',
                                      product_category='e-books',
                                      product_name='book',
                                      num_of_item=100,
                                      shipping_method='NO',
                                      product_profile='None')

    mypayment.set_customer_info(name=f"{request.user}",
                                email=f"{request.user.email}",
                                address1='None',
                                city='None',
                                postcode='None',
                                country='None',
                                phone='None')

    mypayment.set_additional_values(value_a=f"{request.user}")
    response_data = mypayment.init_payment()

    return redirect(response_data['GatewayPageURL'])
Example #3
0
def testpayment(request):
    saved_address = BillingAddress.objects.get_or_create(user=request.user)[0]
    if not saved_address.is_fully_fill():
        messages.info(request, 'plz complete shipping address')
        return redirect('app_payment:checkedout')

    if not request.user.profile.is_fully_fill():
        messages.info(request, 'plz complete profile')
        return redirect('loginapp:use_profile')
    store_id = "ab6079637bdc626"
    app_key= "ab6079637bdc626@ssl"
    mypayment = SSLCSession(sslc_is_sandbox=True, sslc_store_id=store_id,
                            sslc_store_pass=app_key)
    status_url = request.build_absolute_uri(reverse("app_payment:complete"))
    mypayment.set_urls(success_url=status_url, fail_url=status_url,
                       cancel_url=status_url, ipn_url=status_url)
    ordrs_qs = Order.objects.filter(user=request.user, ordered=False)[0]
    order_items = ordrs_qs.orderItems.all()
    item_count = ordrs_qs.orderItems.count()
    order_total = ordrs_qs.get_totals()
    current_user = request.user
    mypayment.set_product_integration(total_amount=Decimal(order_total), currency='BDT', product_category='Mixed',
                                      product_name=order_items, num_of_item=item_count, shipping_method='Cuirer',
                                      product_profile='None')

    mypayment.set_customer_info(name=current_user.profile.fullname, email=current_user.email, address1=current_user.profile.address,
                               address2=current_user.profile.address, city=current_user.profile.city, postcode=current_user.profile.postcode, country=current_user.profile.country,
                               phone=current_user.profile.phone)

    mypayment.set_shipping_info(shipping_to=current_user.profile.fullname, address=saved_address.address, city=saved_address.city, postcode=saved_address.zipcode,
                                country=saved_address.contry)
    response_data = mypayment.init_payment()
    print(response_data)
    return redirect(response_data['GatewayPageURL'])
Example #4
0
def PaymentView(request):
    saved_address = BillingAddress.objects.get_or_create(user=request.user)
    saved_address = saved_address[0]
    if not saved_address.is_fully_filled():
        messages.info(request, "Complete shipping address")
        return redirect('App_Payment:checkout_view')

    if not request.user.profile.is_fully_filled():
        messages.info(request, "Please complete your profile information")
        return redirect('App_Login:profile_view')

    # for payment section
    store_id = 'xyz5f3e8e1ac0821'
    API_key = 'xyz5f3e8e1ac0821@ssl'
    mypayment = SSLCSession(sslc_is_sandbox=True,
                            sslc_store_id=store_id,
                            sslc_store_pass=API_key)

    status_url = request.build_absolute_uri(
        reverse('App_Payment:complete_view'))
    mypayment.set_urls(success_url=status_url,
                       fail_url=status_url,
                       cancel_url=status_url,
                       ipn_url=status_url)

    order_exist = Order.objects.filter(user=request.user, ordered=False)
    order_exist = order_exist[0]
    order_items = order_exist.orderitems.all()
    order_item_count = order_exist.orderitems.count()
    order_total = order_exist.get_totals()
    mypayment.set_product_integration(total_amount=Decimal(order_total),
                                      currency='BDT',
                                      product_category='Mixed',
                                      product_name=order_items,
                                      num_of_item=order_item_count,
                                      shipping_method='Courier',
                                      product_profile='None')

    current_user = request.user
    mypayment.set_customer_info(name=current_user.profile.full_name,
                                email=current_user.email,
                                address1=current_user.profile.address_one,
                                address2=current_user.profile.address_one,
                                city=current_user.profile.city,
                                postcode=current_user.profile.zipcode,
                                country=current_user.profile.country,
                                phone=current_user.profile.phone)

    mypayment.set_shipping_info(shipping_to=current_user.profile.full_name,
                                address=saved_address.address,
                                city=saved_address.city,
                                postcode=saved_address.zipcode,
                                country=saved_address.country)

    response_data = mypayment.init_payment()
    return redirect(response_data['GatewayPageURL'])
Example #5
0
def payment(request):
    saved_address = BillingAddress.objects.get_or_create(user=request.user)[0]

    if not saved_address.is_fully_filled():
        messages.info(request, "Please Complete Billing Address")
        return redirect('payment:checkout')

    if not request.user.profile.is_fully_filled():
        messages.info(request, "Please Complete your profile Details")
        return redirect('home:home')

    store_id = 'rahay5e7c01054d7ed'
    store_pass = '******'
    mypayment = SSLCSession(sslc_is_sandbox=True,
                            sslc_store_id=store_id,
                            sslc_store_pass=store_pass)

    status_url = request.build_absolute_uri(reverse('payment:complete'))

    mypayment.set_urls(success_url=status_url,
                       fail_url=status_url,
                       cancel_url=status_url,
                       ipn_url=status_url)

    order_qs = Order.objects.filter(user=request.user, ordered=False)
    order_items = order_qs[0].orderitems.all()
    order_items_count = order_qs[0].orderitems.count()
    order_total = order_qs[0].get_totals()

    mypayment.set_product_integration(total_amount=Decimal(order_total),
                                      currency='BDT',
                                      product_category='Mixed',
                                      product_name=order_items,
                                      num_of_item=order_items_count,
                                      shipping_method='Courier',
                                      product_profile='None')

    current_user = request.user
    mypayment.set_customer_info(name=current_user.profile.full_name,
                                email=current_user.email,
                                address1=current_user.profile.address,
                                address2=current_user.profile.address,
                                city=current_user.profile.city,
                                postcode=current_user.profile.zipcode,
                                country=current_user.profile.country,
                                phone=current_user.profile.phone)

    mypayment.set_shipping_info(shipping_to=current_user.profile.full_name,
                                address=saved_address.address,
                                city=saved_address.city,
                                postcode=saved_address.postcode,
                                country=saved_address.country)

    response_data = mypayment.init_payment()

    return redirect(response_data['GatewayPageURL'])
def payment(request):
    saved_address = saved_address = BillingsAddress.objects.get_or_create(
        user=request.user)
    saved_address = saved_address[0]
    if not saved_address.is_fully_filled():
        messages.error(request, "Please fill the Billing address Properly")
        return redirect('App_Cart:view_cart')

    if not request.user.profile.is_fully_filled():
        messages.info(request, "Please complete your Profile details")
        return redirect('App_login:edit_profile')

    mypayment = SSLCSession(sslc_is_sandbox=True,
                            sslc_store_id='kdtec5f9ec95a661f1',
                            sslc_store_pass='******')

    status_url = request.build_absolute_uri(reverse('App_payment:complete'))

    mypayment.set_urls(success_url=status_url,
                       fail_url=status_url,
                       cancel_url=status_url,
                       ipn_url=status_url)

    order_queries = Order.objects.filter(user=request.user, ordered=False)
    order_item = order_queries[0].orderitems.all()
    order_item_count = order_queries[0].orderitems.count()
    order_total = order_queries[0].get_totals()

    mypayment.set_product_integration(total_amount=Decimal(order_total),
                                      currency='BDT',
                                      product_category='Mied',
                                      product_name=order_item,
                                      num_of_item=order_item_count,
                                      shipping_method='COD',
                                      product_profile='None')

    current_user = request.user

    mypayment.set_customer_info(name=current_user.profile.full_name,
                                email=current_user.email,
                                address1=current_user.profile.address_1,
                                address2=current_user.profile.address_1,
                                city=current_user.profile.city,
                                postcode=current_user.profile.zipcode,
                                country=current_user.profile.country,
                                phone=current_user.profile.phone)

    mypayment.set_shipping_info(shipping_to=current_user.profile.full_name,
                                address=saved_address.address,
                                city=saved_address.city,
                                postcode=saved_address.zipcode,
                                country=saved_address.country)

    response_data = mypayment.init_payment()
    return redirect(response_data['GatewayPageURL'])
Example #7
0
def payment(request):
    saved_address = BillingAddress.objects.get_or_create(user=request.user)
    saved_address = saved_address[0]
    if not saved_address.is_fully_filled():
        messages.warning(request, "Please complete shipping address.")
        return redirect("payment:checkout")
    if not request.user.profile.is_fully_filled():
        messages.warning(request, "Please complete profile details!")
        return redirect("account:profile")
    mypayment = SSLCSession(sslc_is_sandbox=True,
                            sslc_store_id='#',
                            sslc_store_pass='******')
    status_url = request.build_absolute_uri(reverse("payment:status"))
    mypayment.set_urls(success_url=status_url,
                       fail_url=status_url,
                       cancel_url=status_url,
                       ipn_url=status_url)
    order_qs = Order.objects.filter(user=request.user, ordered=False)
    order_items = order_qs[0].orderitems.all()
    total_items = order_qs[0].orderitems.count()
    total_amount = order_qs[0].get_totals()
    mypayment.set_product_integration(total_amount=Decimal(total_amount),
                                      currency='BDT',
                                      product_category='Mixed',
                                      product_name=order_items,
                                      num_of_item=total_items,
                                      shipping_method='Courier',
                                      product_profile='None')
    #user info
    user = request.user
    name, email = user.profile.fullname, user.email,
    address, address2 = user.profile.address_1, user.profile.address_2,
    city, postcode, country = user.profile.city, user.profile.zipcode, user.profile.country,
    phone = user.profile.phone
    mypayment.set_customer_info(name=name,
                                email=email,
                                address1=address,
                                address2=address2,
                                city=city,
                                postcode=postcode,
                                country=country,
                                phone=phone)
    #shipping address info
    ba_name = saved_address.name
    ba_address = saved_address.address
    ba_city = saved_address.city
    ba_zip_code = saved_address.zip_code
    ba_country = saved_address.country
    mypayment.set_shipping_info(shipping_to=ba_name,
                                address=ba_address,
                                city=ba_city,
                                postcode=ba_zip_code,
                                country=ba_country)
    response_data = mypayment.init_payment()
    return redirect(response_data['GatewayPageURL'])
Example #8
0
def payment(request):
    saved_address = BillingAddress.objects.get_or_create(user=request.user)[0]
    if not saved_address.is_fully_filled():
        messages.info(request, 'inter Shipping address properly')
        return redirect("App_payment:checkout")

    if not request.user.profile.is_fully_filled():
        messages.info(request, 'full field to your profile ')
        return redirect('app_login:profile')
    # payment getway is started hare---------------------------------------------------------------------
    stror_id = 'asadu5f9ab871f41b5'  #mail enformation ssl send me in my email
    api_key = 'asadu5f9ab871f41b5@ssl'  #mail enformation ssl send me in my email
    mypayment = SSLCSession(sslc_is_sandbox=True,
                            sslc_store_id=stror_id,
                            sslc_store_pass=api_key)
    # section two and here is kddkkd---------------------------------------
    status_url = request.build_absolute_uri(reverse("App_payment:complite"))
    mypayment.set_urls(success_url=status_url,
                       fail_url=status_url,
                       cancel_url=status_url,
                       ipn_url=status_url)

    #section three is hare it is very impornt for product------------------
    order_qs = Order.objects.get(user=request.user, ordered=False)
    order_item = order_qs.orderitem.all()
    total_order = order_qs.get_totals()
    mypayment.set_product_integration(total_amount=Decimal(total_order),
                                      currency='BDT',
                                      product_category='oneck',
                                      product_name=order_item,
                                      num_of_item=len(order_item),
                                      shipping_method='Curiar',
                                      product_profile='None')

    #section four is hare it is very imporent for customer information ---------
    current_user = request.user
    mypayment.set_customer_info(name=current_user.profile.full_name,
                                email=current_user.email,
                                address1=current_user.profile.address_1,
                                address2=current_user.profile.address_1,
                                city=current_user.profile.city,
                                postcode=current_user.profile.zipcode,
                                country=saved_address.country,
                                phone=current_user.profile.phone)

    # section five is hare it is very imporent for customer information ---------
    mypayment.set_shipping_info(shipping_to=current_user.profile.full_name,
                                address=saved_address.address,
                                city=saved_address.city,
                                postcode=saved_address.zipcode,
                                country=saved_address.country)

    response_data = mypayment.init_payment()
    return redirect(response_data['GatewayPageURL'])
def payment(request):

    store_id = 'ehsan5fead69e8b4f9'
    API_key = 'ehsan5fead69e8b4f9@ssl'

    mypayment = SSLCSession(sslc_is_sandbox=True,
                            sslc_store_id=store_id,
                            sslc_store_pass=API_key)

    status_url = request.build_absolute_uri(reverse('payment:complete'))
    #print(status_url)

    mypayment.set_urls(success_url=status_url,
                       fail_url=status_url,
                       cancel_url=status_url,
                       ipn_url=status_url)

    mypayment.set_product_integration(total_amount=Decimal(50),
                                      currency='BDT',
                                      product_category='Mixed',
                                      product_name='demo',
                                      num_of_item=2,
                                      shipping_method='YES',
                                      product_profile='None')

    mypayment.set_customer_info(name='John Doe',
                                email='*****@*****.**',
                                address1='demo address',
                                address2='demo address 2',
                                city='Dhaka',
                                postcode='1207',
                                country='Bangladesh',
                                phone='01711111111')

    mypayment.set_shipping_info(shipping_to='demo customer',
                                address='demo address',
                                city='Dhaka',
                                postcode='1209',
                                country='Bangladesh')

    # If you want to post some additional values
    # mypayment.set_additional_values(

    #     value_a='*****@*****.**',
    #     value_b='portalcustomerid',
    #     value_c='1234',
    #     value_d='uuid'
    # )

    response_data = mypayment.init_payment()
    return redirect(response_data['GatewayPageURL'])

    return render(request, 'payment/pay.html', context={})
Example #10
0
def payment_process(request):
    # get the id from session
    order_id = request.session.get('order_id')
    # get the user from the model using id
    order = get_object_or_404(Order, pk=order_id)
    store_id = settings.STORE_ID  # sandbox order id
    store_password = settings.STORE_PASSWORD  # sandbox order pass
    my_payment = SSLCSession(sslc_is_sandbox=True,
                             sslc_store_id=store_id,
                             sslc_store_pass=store_password)
    success_url = request.build_absolute_uri(
        reverse('payments:validation_check'))  # for checking the validation
    fail_url = request.build_absolute_uri(
        reverse('payments:payment_fail'))  # if payment failed
    cancel_url = request.build_absolute_uri(
        reverse('payments:payment_cancel'))  # if payment cancel
    my_payment.set_urls(success_url=success_url,
                        fail_url=fail_url,
                        cancel_url=cancel_url,
                        ipn_url=success_url)
    # get the total cost
    total_cost = order.get_total_cost()  # get the total cost from the method
    # get the total items
    total_items = order.get_total_quantity()

    my_payment.set_product_integration(total_amount=Decimal(total_cost),
                                       currency='BDT',
                                       product_category='Mixed',
                                       product_name='None',
                                       num_of_item=total_items,
                                       shipping_method='Courier',
                                       product_profile='None')

    # customer info
    my_payment.set_customer_info(name=order.name,
                                 email=order.email,
                                 address1=order.address,
                                 city=order.city,
                                 postcode=order.postal_code,
                                 country=order.country,
                                 phone=order.phone)
    # shipping address
    my_payment.set_shipping_info(shipping_to=order.name,
                                 address=order.address,
                                 city=order.city,
                                 postcode=order.postal_code,
                                 country=order.country)

    response_data = my_payment.init_payment()
    # print(response_data)
    return redirect(response_data['GatewayPageURL'])
Example #11
0
def payment(request):
    global purchaseDetails, totalPrice
    user = UserCustom.objects.get(username=request.user.username)
    if request.method == 'POST':
        totalPrice = request.POST.get('totalPrice')
        name = request.POST.get('name')
        email = request.POST.get('email')
        contact = request.POST.get('contact')
        address = request.POST.get('address')
        purchaseDetails = request.POST.get('purchaseDetails')
        mypayment = SSLCSession(sslc_is_sandbox=True,
                                sslc_store_id='naser5f87eff1ddede',
                                sslc_store_pass='******')
        mypayment.set_urls(
            success_url='http://127.0.0.1:8000/completeOrder/' +
            str(request.user.username),
            fail_url='http://127.0.0.1:8000/incompleteOrder/' +
            str(request.user.username),
            cancel_url='http://127.0.0.1:8000/incompleteOrder/' +
            str(request.user.username),
            ipn_url='http://127.0.0.1:8000/')
        mypayment.set_product_integration(total_amount=Decimal(totalPrice),
                                          currency='BDT',
                                          product_category='Payment',
                                          product_name='Product',
                                          num_of_item=1,
                                          shipping_method='YES',
                                          product_profile='None')
        mypayment.set_customer_info(name=request.user.first_name,
                                    email=request.user.email,
                                    address1=address,
                                    address2=address,
                                    city='Dhaka',
                                    postcode='2231',
                                    country='Bangladesh',
                                    phone=contact)
        mypayment.set_shipping_info(shipping_to='Abir',
                                    address='Address',
                                    city='Dhaka',
                                    postcode='1209',
                                    country='Bangladesh')
        response_data = mypayment.init_payment()
        print(response_data)

        return redirect(response_data['GatewayPageURL'])
Example #12
0
def payment(request, pk):
    info = MoneyDonatorInfo.objects.get(id=pk)
    store_id = 'spere5f3aeaafa6b1d'
    api_key = 'spere5f3aeaafa6b1d@ssl'
    mypayment = SSLCSession(sslc_is_sandbox=True,
                            sslc_store_id=store_id,
                            sslc_store_pass=api_key)

    status_url = request.build_absolute_uri(
        reverse('status', kwargs={'pk': info.id}))

    mypayment.set_urls(success_url=status_url,
                       fail_url=status_url,
                       cancel_url=status_url,
                       ipn_url=status_url)

    donator = MoneyDonatorInfo.objects.get(id=pk)
    donate_amount = donator.amount
    mypayment.set_product_integration(total_amount=Decimal(donate_amount),
                                      currency='BDT',
                                      product_category='donation',
                                      product_name='Donate Money',
                                      num_of_item=1,
                                      shipping_method='None',
                                      product_profile='None')

    mypayment.set_customer_info(name=donator.name,
                                email=donator.email,
                                address1='demo address 1',
                                address2='demo address 2',
                                city='Dhaka',
                                postcode='1200',
                                country='Bangladesh',
                                phone=donator.contact)

    mypayment.set_shipping_info(shipping_to=donator.name,
                                address='demo address',
                                city='Dhaka',
                                postcode='1200',
                                country='Bangladesh')

    response_data = mypayment.init_payment()
    return redirect(response_data['GatewayPageURL'])
def payment(request):
    ## get the Billing address
    saved_address = BillingAddress.objects.get_or_create(user=request.user)
    saved_address = saved_address[0]
    ## check again that it is fully filled
    if not saved_address.is_fully_filled():
        messages.info(request,"Please Complete Shipping Address")
        return redirect('App_Payment:chekout')
    
    ## check the profile is filled too
    if not request.user.profile.is_fully_filled():
        messages.info(request,"Please Complete Profile Details")
        return redirect('App_Login:profile')

    store_id = "test5f63e7c01865f"
    API_Key  = "test5f63e7c01865f@ssl"

    mypayment = SSLCSession(sslc_is_sandbox=True,sslc_store_id=store_id,sslc_store_pass=API_Key)
    ## give the redirect url to check the status
    ## when it done where i goes
    status_url = request.build_absolute_uri(reverse('App_Payment:complete'))
    mypayment.set_urls(success_url=status_url,fail_url=status_url,cancel_url=status_url,ipn_url=status_url)

    order_qs = Order.objects.filter(user=request.user,ordered=False)
    order_qs = order_qs[0]

    ## get all the Carts
    order_items = order_qs.orderitems.all()
    ## get how many cart did you get
    order_items_counts = order_qs.orderitems.count()
    ## get the total price
    order_total = order_qs.get_totals()
    mypayment.set_product_integration(total_amount=Decimal(order_total),currency="BDT",product_category='Mixed',product_name=order_items,num_of_item=order_items_counts,shipping_method='Courier',product_profile='None')

    ## now we need to set the customer info
    ## and the shippign address both
    current_user = request.user
    mypayment.set_customer_info(name=current_user.profile.full_name,email=current_user.email,address1=current_user.profile.address_1,address2=current_user.profile.address_1,city=current_user.profile.city,postcode=current_user.profile.zipcode,country=current_user.profile.country,phone=current_user.profile.phone)
    mypayment.set_shipping_info(shipping_to=current_user.profile.full_name,address=saved_address.address,city=saved_address.city,postcode=saved_address.zipcode,country=saved_address.country)
    response_data = mypayment.init_payment()
    print(response_data)
    return redirect(response_data['GatewayPageURL'])
 def get(self, *args, **kwargs):
     order = Cart.objects.get(user=self.request.user, ordered=False)
     no_of_items = order.items.count()
     userprofile = UserProfile.objects.get(user=self.request.user)
     amount = int(order.get_total())
     billing_address = Address.objects.filter(user=self.request.user)[0]
     status_url = self.request.build_absolute_uri(reverse('core:complete'))
     mypayment = SSLCSession(sslc_is_sandbox=True,
                             sslc_store_id=settings.SSLC_STORE_ID,
                             sslc_store_pass=settings.SSLC_STORE_PASSWORD)
     mypayment.set_urls(success_url=status_url,
                        fail_url=status_url,
                        cancel_url=status_url,
                        ipn_url=status_url)
     mypayment.set_product_integration(total_amount=Decimal(f'{amount}'),
                                       currency='BDT',
                                       product_category='clothing',
                                       product_name='demo-product',
                                       num_of_item=no_of_items,
                                       shipping_method='YES',
                                       product_profile=userprofile)
     mypayment.set_customer_info(
         name=self.request.user.username,
         email='*****@*****.**',
         address1=
         f'{billing_address.apartment_address + billing_address.street_address}',
         address2=
         f'{billing_address.apartment_address + billing_address.street_address}',
         city='Dhaka',
         postcode='1207',
         country='Bangladesh',
         phone='01711111111')
     mypayment.set_shipping_info(
         shipping_to=
         f'{billing_address.apartment_address + billing_address.street_address}',
         address=
         f'{billing_address.apartment_address + billing_address.street_address}',
         city='Dhaka',
         postcode='1209',
         country='Bangladesh')
     response_data = mypayment.init_payment()
     return redirect(response_data['GatewayPageURL'])
Example #15
0
def payment(request):
    mypayment = SSLCSession(sslc_is_sandbox=True,
                            sslc_store_id='xebec5fecfeb01b53c',
                            sslc_store_pass='******')
    status_url = request.build_absolute_uri(reverse('payment-status'))
    # print(status_url)
    mypayment.set_urls(success_url=status_url,
                       fail_url=status_url,
                       cancel_url=status_url,
                       ipn_url=status_url)

    schedule_qs = Schedule.objects.filter()

    mypayment.set_product_integration(total_amount=Decimal('20.20'),
                                      currency='BDT',
                                      product_category='health',
                                      product_name='doctor-apointment',
                                      num_of_item=1,
                                      shipping_method='Billing',
                                      product_profile='None')
    user = request.user
    mypayment.set_customer_info(name=f"{user.first_name} {user.last_name}",
                                email=user.email,
                                address1='demo address',
                                address2='demo address 2',
                                city='Dhaka',
                                postcode='1207',
                                country='Bangladesh',
                                phone=user.mobile)

    mypayment.set_shipping_info(
        shipping_to=f"{user.first_name} {user.last_name}",
        address='demo address',
        city='Dhaka',
        postcode='1209',
        country='Bangladesh')

    response_data = mypayment.init_payment()
    print(response_data)

    return redirect(response_data['GatewayPageURL'])
Example #16
0
def payment(request):
    saved_address = BillingAddress.objects.get(user=request.user)
    '''Here if we use get() query_set,we don't have need to use indexing for access object value,
    otherwise we need  indexing  to access saved_address value  '''
    #print(saved_address)
    if not saved_address.is_fully_filled():
        messages.warning(request, "Please Complete Your Shipping Address !")
        return redirect('Payment_App:checkout')
    if not request.user.profile.is_fully_field():
        messages.warning(request, "Please Complete Your Profile Info !")
        return redirect('Login_App:profile')

    # From SSlCOMMERZ gmail notification:
    store_id = 'sajja5f61279af322c'
    API_key = 'sajja5f61279af322c@ssl'
    mypayment = SSLCSession(sslc_is_sandbox=True,
                            sslc_store_id=store_id,
                            sslc_store_pass=API_key)
    #print('request---->',request)
    status_url = request.build_absolute_uri(reverse('Payment_App:complete'))
    #print(status_url)
    mypayment.set_urls(success_url=status_url,
                       fail_url=status_url,
                       cancel_url=status_url,
                       ipn_url=status_url)

    order_qs = Order.objects.get(user=request.user, ordered=False)
    '''Here if we use get() query_set,we don't have need to use indexing for access object value,
    otherwise we need  indexing  to access objects value  '''
    #print(order_qs)
    order_items = order_qs.orderitems.all()
    order_items_count = order_qs.orderitems.count()
    order_total = order_qs.get_totals()

    mypayment.set_product_integration(total_amount=Decimal(order_total),
                                      currency='BDT',
                                      product_category='Mixed',
                                      product_name=order_items,
                                      num_of_item=order_items_count,
                                      shipping_method='Courier',
                                      product_profile='None')

    current_user = request.user
    mypayment.set_customer_info(name=current_user.profile.full_name,
                                email=current_user.email,
                                address1=current_user.profile.address_1,
                                address2=current_user.profile.address_1,
                                city=current_user.profile.city,
                                postcode=current_user.profile.zipcode,
                                country=current_user.profile.country,
                                phone=current_user.profile.phone)

    mypayment.set_shipping_info(shipping_to=current_user.profile.full_name,
                                address=saved_address.address,
                                city=saved_address.city,
                                postcode=saved_address.zipcode,
                                country=saved_address.country)

    response_data = mypayment.init_payment()
    #print(response_data)

    return redirect(response_data['GatewayPageURL'])
Example #17
0
def enrollment(request, username):
    userall = AllUsers.objects.get(username=username)
    if request.user.is_authenticated and request.user.username == username and userall.accounts_type == 'Student':

        subjects = Courses.objects.all()
        students = Student.objects.get(username=username)

        if request.method == 'POST':
            version = request.POST.get('version')
            subject = request.POST.get('subject')

            desiredCourse = Courses.objects.get(slug=subject)

            if Enrollment.objects.filter(uname=username,
                                         subject=desiredCourse.slug).exists():
                messages.info(request,
                              'You are already enrolled in this course')
                return redirect('/enrollment/' + str(username))
            else:

                # integration part
                mypayment = SSLCSession(
                    sslc_is_sandbox=True,
                    sslc_store_id='naser5f87eff1ddede',
                    sslc_store_pass='******')
                mypayment.set_urls(
                    success_url='http://' + str(request.META['HTTP_HOST']) +
                    '/enrollmentCheckout/' + str(version) + '/' +
                    str(subject) + '/2000/' + str(username),
                    fail_url='http://' + str(request.META['HTTP_HOST']) +
                    '/enrollmentCheckoutFail',
                    cancel_url='http;://' + str(request.META['HTTP_HOST']) +
                    '/enrollmentCancel',
                    ipn_url=str(request.META['HTTP_HOST']) +
                    '/enrollmentConfirmation')
                mypayment.set_product_integration(total_amount=Decimal(
                    desiredCourse.price),
                                                  currency='BDT',
                                                  product_category='Course',
                                                  product_name=subject,
                                                  num_of_item=1,
                                                  shipping_method='YES',
                                                  product_profile='None')
                mypayment.set_customer_info(name=students.fname + ' ' +
                                            students.lname,
                                            email=students.email,
                                            address1='Address',
                                            address2='Address',
                                            city='Dhaka',
                                            postcode='2231',
                                            country='Bangladesh',
                                            phone=students.contact)
                mypayment.set_shipping_info(shipping_to=students.fname + ' ' +
                                            students.lname,
                                            address='Address',
                                            city='Dhaka',
                                            postcode='1209',
                                            country='Bangladesh')
                response_data = mypayment.init_payment()
                print(response_data)

                return redirect(response_data['GatewayPageURL'])
                # return HttpResponse(desiredCourse)

    else:
        messages.success(request, 'Please log in as a student')
        return redirect('/accounts/login')
        # return HttpResponse(students.enrolled)
    params = {'subjects': subjects}
    return render(request, 'course-admission.html', params)
Example #18
0
def PaymentView(request):
    cart = ShopCart.objects.filter(user_id=request.user.id)
    if cart.exists():
        # Clear & Delete shopcart
        cart.delete()
        request.session['cart_items'] = 0
        last_order = Order.objects.last()
        order_query = OrderProduct.objects.filter(order_id=last_order.pk)
        store_id = 'shajb606c38852a3a2'
        api_key = 'shajb606c38852a3a2@ssl'
        mypayment = SSLCSession(sslc_is_sandbox=True,
                                sslc_store_id=store_id,
                                sslc_store_pass=api_key)
        #status_url = request.build_absolute_uri()  #for getting running view url
        status_url = request.build_absolute_uri(
            reverse('Order:Order_PaymentComplete'))
        print(status_url)
        mypayment.set_urls(success_url=status_url,
                           fail_url=status_url,
                           cancel_url=status_url,
                           ipn_url=status_url)
        # for query in order_query:
        #     order_items.add(query)
        # order_items = order_query[0]
        order_items_count = order_query.count()
        # price_query = ShopCart.objects.filter(user_id=request.user.id)
        # print(price_query)
        total_price = 0
        for price in order_query:
            total_price += price.amount
        mypayment.set_product_integration(total_amount=Decimal(total_price),
                                          currency='BDT',
                                          product_category='Mixed',
                                          product_name=order_query,
                                          num_of_item=order_items_count,
                                          shipping_method='Local Shipping',
                                          product_profile='None')
        customer_info = Order.objects.last()
        if customer_info.first_name is None:
            return redirect("Order:CheckoutView")
        elif customer_info.last_name is None:
            return redirect("Order:CheckoutView")
        elif customer_info.email is None:
            return redirect("Order:CheckoutView")
        elif customer_info.city is None:
            return redirect("Order:CheckoutView")
        elif customer_info.zipcode is None:
            return redirect("Order:CheckoutView")
        elif customer_info.country is None:
            return redirect("Order:CheckoutView")
        elif customer_info.phone is None:
            return redirect("Order:CheckoutView")
        elif customer_info.address is None:
            return redirect("Order:CheckoutView")
        mypayment.set_customer_info(name=customer_info.first_name +
                                    customer_info.last_name,
                                    email=customer_info.email,
                                    address1=customer_info.address,
                                    address2=customer_info.address,
                                    city=customer_info.city,
                                    postcode=customer_info.zipcode,
                                    country=customer_info.country,
                                    phone=customer_info.phone)
        mypayment.set_shipping_info(shipping_to=customer_info.first_name +
                                    customer_info.last_name,
                                    address=customer_info.address,
                                    city=customer_info.city,
                                    postcode=customer_info.zipcode,
                                    country=customer_info.country)

        response_data = mypayment.init_payment()
    else:
        return HttpResponseRedirect(reverse('Home:IndexView'))
    context = {}
    return redirect(response_data['GatewayPageURL'])