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
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
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
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
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
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
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