Beispiel #1
0
    def get_data(self):
        """
        Test the eWAY auth complete functionality.
        """
        customer = Customer()
        customer.first_name = "Joe"
        customer.last_name = "Bloggs"
        customer.email = "*****@*****.**"
        customer.address = "35 rue de la fédération, Somewhere ACT".decode(
            'utf-8')
        customer.postcode = "2609"
        customer.invoice_description = "Testing"
        customer.invoice_reference = "INV120394"
        customer.country = "AU"

        credit_card = CreditCard()
        credit_card.holder_name = '%s %s' % (
            customer.first_name,
            customer.last_name,
        )
        credit_card.number = "4444333322221111"
        credit_card.expiry_month = 10
        credit_card.expiry_year = 12
        credit_card.verification_number = "123"
        credit_card.ip_address = "127.0.0.1"

        return [customer, credit_card]
Beispiel #2
0
    def test_client(self):
        customer = Customer()
        customer.first_name = "Joe"
        customer.last_name = "Bloggs"
        customer.email = "*****@*****.**"
        customer.address = "123 Someplace Street, Somewhere ACT"
        customer.postcode = "2609"
        customer.invoice_description = "Testing"
        customer.invoice_reference = "INV120394"
        customer.country = "AU"

        credit_card = CreditCard()
        credit_card.holder_name = '%s %s' % (
            customer.first_name,
            customer.last_name,
        )
        credit_card.number = "4444333322221111"
        credit_card.expiry_month = 10
        credit_card.expiry_year = 12
        credit_card.verification_number = "123"
        credit_card.ip_address = "127.0.0.1"

        if customer.is_valid() and credit_card.is_valid():
            response = self.eway_client.authorize(Decimal("10.08"),
                                                  credit_card=credit_card,
                                                  customer=customer,
                                                  reference="123456")
            self.failUnless(response.success)
Beispiel #3
0
    def get_data(self):
        """
        Test the eWAY auth complete functionality.
        """
        customer = Customer()
        customer.first_name = "Joe"
        customer.last_name = "Bloggs"
        customer.email = "*****@*****.**"
        customer.address = "35 rue de la fédération, Somewhere ACT".decode('utf-8')
        customer.postcode = "2609"
        customer.invoice_description = "Testing"
        customer.invoice_reference = "INV120394"
        customer.country = "AU"

        credit_card = CreditCard()
        credit_card.holder_name = '%s %s' % (customer.first_name, customer.last_name,)
        credit_card.number = "4444333322221111" 
        credit_card.expiry_month = 10
        credit_card.expiry_year = 12
        credit_card.verification_number = "123"
        credit_card.ip_address = "127.0.0.1"
        
        return [customer, credit_card]
Beispiel #4
0
def payment(request):
    # TODO logging needs to be added into here
    msg = ''
    form = ''
    t = loader.get_template('payment.html')
    message = ''
    if request.session.get("order_id", None):
        order = Order.objects.get(pk=request.session.get("order_id", 0))
    else:
        raise ValueError("Order not found")
    '''-------------------------------paypal-------------------------------------------------'''
    if request.POST.get("paypalcheckout.x", None):
        if float(order.getShippingCharged()) != 0:
            msgg = common.getResponse(order)

            if msgg['ACK'] == 'Success':

                return HttpResponseRedirect(
                    "https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=%s&useraction=commit"
                    % msgg['TOKEN'])
            else:
                msg = msgg
                '''----------------------------------------------------------------------------------------'''

    elif request.POST:
        rp = request.POST.copy()
        if rp.get("editmyorder"):
            return HttpResponseRedirect("cart.html")
        form = CreditCardForm(rp)
        if form.is_valid():
            profile = order.user.get_profile()
            shipping = profile.shipping_set.all()
            billing = profile.billing_set.all()
            customer = Customer()
            names = form.cleaned_data.get("name")
            firstname = names[0]
            lastname = names[1]
            customer.first_name = firstname
            customer.last_name = lastname
            customer.email = billing[0].email
            customer.address = billing[0].address
            customer.postcode = billing[0].postcode
            customer.invoice_description = "Order from eastbourneart"
            customer.invoice_reference = order.getOrderNumber()
            customer.country = billing[0].country

            #op = CreditPayment()
            credit_card = CreditCard()
            #op.type = form.cleaned_data.get("type")
            credit_card.number = form.cleaned_data.get("number")
            credit_card.expiry_month = form.cleaned_data.get("expiryMonth")
            credit_card.expiry_year = form.cleaned_data.get("expiryYear")

            credit_card.holder_name = '%s %s' % (
                firstname,
                lastname,
            )
            credit_card.verification_number = form.cleaned_data.get("CVV")
            credit_card.ip_address = request.META["REMOTE_ADDR"]

            amount = float(order.total_charged)

            if customer.is_valid() and credit_card.is_valid():

                #17019375
                eway_client = EwayPaymentClient('17019375',
                                                config.REAL_TIME_CVN, True)
                response = eway_client.authorize(Decimal(str(amount)),
                                                 credit_card=credit_card,
                                                 customer=customer)
                if response.status.lower() == 'true':
                    order.status = OrderStatus.objects.get(
                        status__iexact=settings.TXT_SHOP_ORDER_STATUS_ORDERED)
                    order.save()
                    payment = True
                    t = loader.get_template('orderconfirmationemail.html')
                    d = {
                        "profile": profile,
                        "shipping": shipping[0],
                        "billing": billing[0],
                        'payment': payment
                    }
                    c = RequestContext(request, common.commonDict(d, request))
                    msg = t.render(c)
                    email = EmailMultiAlternatives(
                        'EASTBOURNEART Order Received - Order ' +
                        order.getOrderNumber(), msg,
                        '*****@*****.**',
                        ['*****@*****.**', order.user.email])
                    email.attach_alternative(msg, "text/html")
                    email.send()
                    '''---------------------------------------inventory----------------------------------------------'''
                    pos = order.productorder_set.all()
                    for x in pos:
                        if x.product.inventory:
                            x.product.inventory -= x.quantity
                            x.product.save()
                            if x.product.inventory <= x.product.maximum_quantity_wholesale:
                                t = loader.get_template('productinshort.html')
                                c = RequestContext(request,
                                                   {'product': x.product})
                                msg = t.render(c)
                                send_mail(
                                    'EASTBOURNEART Product In Short - Product '
                                    + x.product.title,
                                    msg,
                                    '*****@*****.**', [
                                        '*****@*****.**',
                                        '*****@*****.**'
                                    ],
                                    fail_silently=False)
                    '''----------------------------------------------------------------------------------------------'''
                    '''coupon =  request.session.get('coupon')
                    coupons = Coupon.objects.all()
                    for x in coupons:
                        r = x if x.checkCode(coupon) else None'''
                    #if r:
                    #r.addUsed(coupon)
                    # send_mail('EASTBOURNEART Order Received - Order '+ order.getOrderNumber(), msg, '*****@*****.**', [order.user.email], fail_silently=False)
                    request.session["order_id"] = None
                    request.session['coupon'] = ''
                    return HttpResponseRedirect("success%s.html" % order.id)
                else:
                    message = response.error

            else:
                return HttpResponse("ERROR: %s" %
                                    "Please supply all required infomation")
    else:
        form = CreditCardForm()
    country = request.session.get("shippingcountry", None)
    postcode = request.session.get("shippingpostcode", None)
    weight = order.getTotalWeight()
    try:
        if country.strip().lower() == "australia":
            price = postAustralia(getBoxes(order), getBoxWeight(order),
                                  postcode, order.getTotal())
        else:
            price = postInternational(getBoxes(order), getBoxWeight(order),
                                      postcode, country, order.getTotal())
        if not price:
            price = "?"
        price = 0.00 if price == 'free' else price
    except Exception, e:
        price = "?"