Exemplo n.º 1
0
def process(request):
    # Transaction results
    APPROVED = '1'
    DECLINED = '2'
    ERROR = '3'
    HELD_FOR_REVIEW = '4'
    postdata = request.POST.copy()
    card_num = postdata.get('credit_card_number', '')
    exp_month = postdata.get('credit_card_expire_month', '')
    exp_year = postdata.get('credit_card_expire_year', '')
    exp_date = exp_month + exp_year
    cvv = postdata.get('credit_card_cvv', '')
    amount = cart.cart_subtotal(request)
    results = {}
    response = authnet.do_auth_capture(amount=amount,
                                       card_num=card_num,
                                       exp_date=exp_date,
                                       card_cvv=cvv)
    if response[0] == APPROVED:
        transaction_id = response[6]
        order = create_order(request, transaction_id)
        results = {'order_number':order.id, 'message':''}
    if response[0] == DECLINED:
        results = {'order_number':0,
                   'message':'There is a problem with your credit card.'}
    if response[0] == ERROR or response[0] == HELD_FOR_REVIEW:
        results = {'order_number':0, 'message':'Error processing your order.'}
    return results
Exemplo n.º 2
0
def show_cart(request, template_name="cart/cart.html"):
    #update the csrf token
    c = {}
    c.update(csrf(request))

    if request.method =='POST':

        postdata = request.POST.copy()
        if postdata['submit'] == 'Remove':
            cart.remove_from_cart(request)
        if postdata['submit'] == 'Update':
            cart.update_cart(request)
        if postdata['submit'] == 'Checkout':
            #get the checkout url from checkout.checkout.py
            checkout_url = checkout.get_checkout_url(request)
            print checkout_url
            return HttpResponseRedirect(checkout_url)
    cart_items = cart.get_cart_items(request)
    cart_subtotal = cart.cart_subtotal(request)
#    cart_item_count = cart.cart_item_count(request)
    
    page_title = 'Shopping Cart'
    #for google checkout button
    merchant_id = settings.GOOGLE_CHECKOUT_MERCHANT_ID
    return render_to_response(template_name, locals(),context_instance=RequestContext(request))
Exemplo n.º 3
0
def process(request):
    # Transaction results
    APPROVED = '1'
    DECLINED = '2'
    ERROR = '3'
    HELD_FOR_REVIEW = '4'
    postdata = request.POST.copy()
    card_num = postdata.get('credit_card_number', '')
    exp_month = postdata.get('credit_card_expire_month', '')
    exp_year = postdata.get('credit_card_expire_year', '')
    exp_date = exp_month + exp_year
    cvv = postdata.get('credit_card_cvv', '')
    amount = cart.cart_subtotal(request)
    results = {}
    response = authnet.do_auth_capture(amount=amount,
                                       card_num=card_num,
                                       exp_date=exp_date,
                                       card_cvv=cvv)
    if response[0] == APPROVED:
        transaction_id = response[6]
        order = create_order(request, transaction_id)
        results = {'order_number': order.id, 'message': ''}
    if response[0] == DECLINED:
        results = {
            'order_number': 0,
            'message': 'There is a problem with your credit card.'
        }
    if response[0] == ERROR or response[0] == HELD_FOR_REVIEW:
        results = {
            'order_number': 0,
            'message': 'Error processing your order.'
        }
    return results
Exemplo n.º 4
0
def show_cart(request, template_name="cart/cart.html"):
    #update the csrf token
    c = {}
    c.update(csrf(request))

    if request.method == 'POST':

        postdata = request.POST.copy()
        if postdata['submit'] == 'Remove':
            cart.remove_from_cart(request)
        if postdata['submit'] == 'Update':
            cart.update_cart(request)
        if postdata['submit'] == 'Checkout':
            #get the checkout url from checkout.checkout.py
            checkout_url = checkout.get_checkout_url(request)
            print checkout_url
            return HttpResponseRedirect(checkout_url)
    cart_items = cart.get_cart_items(request)
    cart_subtotal = cart.cart_subtotal(request)
    #    cart_item_count = cart.cart_item_count(request)

    page_title = 'Shopping Cart'
    #for google checkout button
    merchant_id = settings.GOOGLE_CHECKOUT_MERCHANT_ID
    return render_to_response(template_name,
                              locals(),
                              context_instance=RequestContext(request))
Exemplo n.º 5
0
def show_cart(request, template_name="cart/cart.html"):
    if request.method == 'POST':
        postdata = request.POST.copy()
        if postdata['submit'] == 'Remove':
            cart.remove_from_cart(request)
        if postdata['submit'] == 'Update':
            cart.update_cart(request)
    cart_items = cart.get_cart_items(request)
    page_title = 'Shopping Cart'
    cart_subtotal = cart.cart_subtotal(request)
    return render_to_response(template_name, locals(), context_instance=RequestContext(request))
def process(request):
    """ takes a POST request containing valid order data; pings the payment gateway with the billing 
    information and returns a Python dictionary with two entries: 'order_number' and 'message' based on
    the success of the payment processing. An unsuccessful billing will have an order_number of 0 and an error message, 
    and a successful billing with have an order number and an empty string message.
    
    """
    # Transaction results
    APPROVED = '1'
    DECLINED = '2'
    ERROR = '3'
    HELD_FOR_REVIEW = '4'

    postdata = request.POST.copy()
    card_num = postdata.get('credit_card_number', '')
    exp_month = postdata.get('credit_card_expire_month', '')
    exp_year = postdata.get('credit_card_expire_year', '')
    exp_date = exp_month + exp_year
    cvv = postdata.get('credit_card_cvv', '')
    amount = cart.cart_subtotal(request)

    #---- We try to update item stock here, but no luck here----
    #  flag = True
    #  cartItemList = cart.get_cart_items(request)
    #  for item in cartItemList:
    #      productInDB = get_object_or_404(Product, slug=item.product.slug)
    #      if((productInDB.quantity - item.quantity) >= 0):
    #          productInDB.quantity -= item.quantity
    #      else:
    #          flag = False;

    results = {}

    response = authnet.do_auth_capture(amount=amount,
                                       card_num=card_num,
                                       exp_date=exp_date,
                                       card_cvv=cvv)
    if response[0] == APPROVED:
        transaction_id = response[6]
        order = create_order(request, transaction_id)
        results = {'order_number': order.id, 'message': u''}
    if response[0] == DECLINED:
        results = {
            'order_number': 0,
            'message': u'There is a problem with your credit card.'
        }
    if response[0] == ERROR or response[0] == HELD_FOR_REVIEW:
        results = {
            'order_number': 0,
            'message': u'Error processing your order.'
        }
    return results
def process(request):
    """ takes a POST request containing valid order data; pings the payment gateway with the billing 
    information and returns a Python dictionary with two entries: 'order_number' and 'message' based on
    the success of the payment processing. An unsuccessful billing will have an order_number of 0 and an error message, 
    and a successful billing with have an order number and an empty string message.
    
    """
    # Transaction results
    APPROVED = '1'
    DECLINED = '2'
    ERROR = '3'
    HELD_FOR_REVIEW = '4'
    
    postdata = request.POST.copy()
    card_num = postdata.get('credit_card_number','')
    exp_month = postdata.get('credit_card_expire_month','')
    exp_year = postdata.get('credit_card_expire_year','')
    exp_date = exp_month + exp_year
    cvv = postdata.get('credit_card_cvv','')
    amount = cart.cart_subtotal(request)
  
  #---- We try to update item stock here, but no luck here---- 
  #  flag = True
  #  cartItemList = cart.get_cart_items(request)
  #  for item in cartItemList:
  #      productInDB = get_object_or_404(Product, slug=item.product.slug)
  #      if((productInDB.quantity - item.quantity) >= 0):
  #          productInDB.quantity -= item.quantity
  #      else:
  #          flag = False;
            
    
    results = {}
    
   
    response = authnet.do_auth_capture(amount=amount, 
                                       card_num=card_num, 
                                       exp_date=exp_date,
                                       card_cvv=cvv)
    if response[0] == APPROVED:       
        transaction_id = response[6]
        order = create_order(request, transaction_id)
        results = {'order_number': order.id, 'message': u''}
    if response[0] == DECLINED:
        results = {'order_number': 0, 'message': u'There is a problem with your credit card.'}
    if response[0] == ERROR or response[0] == HELD_FOR_REVIEW:
        results = {'order_number': 0, 'message': u'Error processing your order.'}
    return results
Exemplo n.º 8
0
def show_cart(request, template_name):
    if request.method == 'POST':
        postdata = request.POST.copy()
        if postdata['submit'] == 'Remove':
            cart.remove_from_cart(request)
        if postdata['submit'] == 'Update':
            cart.update_cart(request)
        if postdata['submit'] == 'Checkout':
            checkout_url = checkout.get_checkout_url(request)
            return HttpResponseRedirect(checkout_url)
    cart_items = cart.get_cart_items(request)
    page_title = 'Shopping Cart'
    cart_subtotal = cart.cart_subtotal(request)
    # for Google Checkout button
    merchant_id = settings.GOOGLE_CHECKOUT_MERCHANT_ID
    return render_to_response(template_name,
                              locals(),
                              context_instance=RequestContext(request))
Exemplo n.º 9
0
def process(request):
    """ takes a POST request containing valid order data; pings the payment gateway with the billing 
    information and returns a Python dictionary with two entries: 'order_number' and 'message' based on
    the success of the payment processing. An unsuccessful billing will have an order_number of 0 and an error message, 
    and a successful billing with have an order number and an empty string message.
    
    """
    # Transaction results
    APPROVED = '1'
    DECLINED = '2'
    ERROR = '3'
    HELD_FOR_REVIEW = '4'

    postdata = request.POST.copy()
    card_num = postdata.get('credit_card_number', '')
    exp_month = postdata.get('credit_card_expire_month', '')
    exp_year = postdata.get('credit_card_expire_year', '')
    exp_date = exp_month + exp_year
    cvv = postdata.get('credit_card_cvv', '')
    amount = cart.cart_subtotal(request)

    results = {}

    response = authnet.do_auth_capture(amount=amount,
                                       card_num=card_num,
                                       exp_date=exp_date,
                                       card_cvv=cvv)
    if response[0] == APPROVED:
        transaction_id = response[6]
        order = create_order(request, transaction_id)
        results = {'order_number': order.id, 'message': u''}
    if response[0] == DECLINED:
        results = {
            'order_number': 0,
            'message': u'There is a problem with your credit card.'
        }
    if response[0] == ERROR or response[0] == HELD_FOR_REVIEW:
        results = {
            'order_number': 0,
            'message': u'Error processing your order.'
        }
    return results
Exemplo n.º 10
0
def show_cart(request, template_name="cart/cart.html"):
    """ view function for the page displaying the customer shopping cart, and allows for the updating of quantities
    and removal product instances 
    
    """
    if request.method == 'POST':
        postdata = request.POST.copy()
        if postdata['submit'] == 'Remove':
            cart.remove_from_cart(request)
        if postdata['submit'] == 'Update':
            cart.update_cart(request)
        if postdata['submit'] == 'Checkout':
            checkout_url = checkout.get_checkout_url(request)
            return HttpResponseRedirect(checkout_url)
    cart_items = cart.get_cart_items(request)
    page_title = 'Shopping Cart'
    cart_subtotal = cart.cart_subtotal(request)
    # need for Google Checkout button
    merchant_id = settings.GOOGLE_CHECKOUT_MERCHANT_ID
    return render_to_response(template_name, locals(),context_instance=RequestContext(request))
Exemplo n.º 11
0
def show_cart(request, template_name="cart/cart.html"):
    """ view function for the page displaying the customer shopping cart, and allows for the updating of quantities
    and removal product instances 
    
    """
    if request.method == 'POST':
        postdata = request.POST.copy()
        if postdata['submit'] == 'Remove':
            cart.remove_from_cart(request)
        if postdata['submit'] == 'Update':
            cart.update_cart(request)
        if postdata['submit'] == 'Checkout':
            checkout_url = checkout.get_checkout_url(request)
            return HttpResponseRedirect(checkout_url)
    cart_items = cart.get_cart_items(request)
    page_title = 'Shopping Cart'
    cart_subtotal = cart.cart_subtotal(request)
    # need for Google Checkout button
    merchant_id = settings.GOOGLE_CHECKOUT_MERCHANT_ID
    return render_to_response(template_name,
                              locals(),
                              context_instance=RequestContext(request))
Exemplo n.º 12
0
def process(request):
    """ takes a POST request containing valid order data; pings the payment gateway with the billing 
    information and returns a Python dictionary with two entries: 'order_number' and 'message' based on
    the success of the payment processing. An unsuccessful billing will have an order_number of 0 and an error message, 
    and a successful billing with have an order number and an empty string message.
    
    """
    # Transaction results
    APPROVED = '1'
    DECLINED = '2'
    ERROR = '3'
    HELD_FOR_REVIEW = '4'
    
    postdata = request.POST.copy()
    card_num = postdata.get('credit_card_number','')
    exp_month = postdata.get('credit_card_expire_month','')
    exp_year = postdata.get('credit_card_expire_year','')
    exp_date = exp_month + exp_year
    cvv = postdata.get('credit_card_cvv','')
    amount = cart.cart_subtotal(request)
    
    results = {}
    
    response = authnet.do_auth_capture(amount=amount, 
                                       card_num=card_num, 
                                       exp_date=exp_date,
                                       card_cvv=cvv)
    if response[0] == APPROVED:
        transaction_id = response[6]
        order = create_order(request, transaction_id)
        results = {'order_number': order.id, 'message': u''}
    if response[0] == DECLINED:
        results = {'order_number': 0, 'message': u'There is a problem with your credit card.'}
    if response[0] == ERROR or response[0] == HELD_FOR_REVIEW:
        results = {'order_number': 0, 'message': u'Error processing your order.'}
    return results
Exemplo n.º 13
0
def process(request):
    #Transaction results
    APPROVED = '1'
    DECLINED = '2'
    ERROR = '3'
    HELD_FOR_REVIEW = '4'
    
    #get the data from the post request
    postdata = request.POST.copy()
    card_num = postdata.get('credit_card_number','')
    exp_month = postdata.get('credit_card_expire_month','')
    exp_year = postdata.get('credit_card_expire_year','')
    exp_date = exp_month + exp_year
    cvv = postdata.get('credit_card_cvv','')
    amount = cart.cart_subtotal(request)

    #get data about the customer
    b_name = postdata.get('billing_name','')
    b_address = postdata.get('billing_address1','')
    b_city = postdata.get('billing_city','')
    b_state = postdata.get('billing_state','')
    b_zip = postdata.get('billing_zip','')
    b_country = postdata.get('billing_country','')
    u_email = postdata.get('email','')
    u_phone = postdata.get('phone','')
    s_name = postdata.get('shipping_name','')
    s_address = postdata.get('shipping_address1','')
    s_city = postdata.get('shipping_city','')
    s_state = postdata.get('shipping_state','')
    s_zip = postdata.get('shipping_zip','')
    s_country = postdata.get('shipping_country','')

    results = {}

    #capture the data and send to authorize.net
    response = authnet.do_auth_capture(amount=amount,
                                       card_num=card_num,
                                       exp_date=exp_date,
                                       card_cvv=cvv,
                                       bill_name=b_name,
                                       bill_address=b_address,
                                       bill_city=b_city,
                                       bill_state=b_state,
                                       bill_zip=b_zip,
                                       bill_country=b_country,
                                       email = u_email,
                                       phone = u_phone,
                                       ship_name = s_name,
                                       ship_address = s_address,
                                       ship_city = s_city,
                                       ship_state = s_state,
                                       ship_zip=s_zip,
                                       ship_country = s_country)
    if response[0] == APPROVED:
        transaction_id = response[6]
        order = create_order(request, transaction_id)
        results = {'order_number':order.id, 'message':''}
    if response[0] == DECLINED:
        results = {'order_number':0,'message':'There is a problem with your credit card.'}
    if response[0] == ERROR or response[0] == HELD_FOR_REVIEW:
        results = {'order_number':0,'message':'Error processing your order.'}
    print results
    print response[0]
    return results
Exemplo n.º 14
0
def process(request):
    #Transaction results
    APPROVED = '1'
    DECLINED = '2'
    ERROR = '3'
    HELD_FOR_REVIEW = '4'

    #get the data from the post request
    postdata = request.POST.copy()
    card_num = postdata.get('credit_card_number', '')
    exp_month = postdata.get('credit_card_expire_month', '')
    exp_year = postdata.get('credit_card_expire_year', '')
    exp_date = exp_month + exp_year
    cvv = postdata.get('credit_card_cvv', '')
    amount = cart.cart_subtotal(request)

    #get data about the customer
    b_name = postdata.get('billing_name', '')
    b_address = postdata.get('billing_address1', '')
    b_city = postdata.get('billing_city', '')
    b_state = postdata.get('billing_state', '')
    b_zip = postdata.get('billing_zip', '')
    b_country = postdata.get('billing_country', '')
    u_email = postdata.get('email', '')
    u_phone = postdata.get('phone', '')
    s_name = postdata.get('shipping_name', '')
    s_address = postdata.get('shipping_address1', '')
    s_city = postdata.get('shipping_city', '')
    s_state = postdata.get('shipping_state', '')
    s_zip = postdata.get('shipping_zip', '')
    s_country = postdata.get('shipping_country', '')

    results = {}

    #capture the data and send to authorize.net
    response = authnet.do_auth_capture(amount=amount,
                                       card_num=card_num,
                                       exp_date=exp_date,
                                       card_cvv=cvv,
                                       bill_name=b_name,
                                       bill_address=b_address,
                                       bill_city=b_city,
                                       bill_state=b_state,
                                       bill_zip=b_zip,
                                       bill_country=b_country,
                                       email=u_email,
                                       phone=u_phone,
                                       ship_name=s_name,
                                       ship_address=s_address,
                                       ship_city=s_city,
                                       ship_state=s_state,
                                       ship_zip=s_zip,
                                       ship_country=s_country)
    if response[0] == APPROVED:
        transaction_id = response[6]
        order = create_order(request, transaction_id)
        results = {'order_number': order.id, 'message': ''}
    if response[0] == DECLINED:
        results = {
            'order_number': 0,
            'message': 'There is a problem with your credit card.'
        }
    if response[0] == ERROR or response[0] == HELD_FOR_REVIEW:
        results = {
            'order_number': 0,
            'message': 'Error processing your order.'
        }
    print results
    print response[0]
    return results