Ejemplo n.º 1
0
def credit_pay_ship_info(request, payment_module):
    #First verify that the customer exists
    contact = Contact.from_request(request, create=False)
    if contact is None:
        url = lookup_url(payment_module, 'satchmo_checkout-step1')
        return http.HttpResponseRedirect(url)

    #Verify we still have items in the cart
    if request.session.get('cart', False):
        tempCart = Cart.objects.get(id=request.session['cart'])
        if tempCart.numItems == 0:
            template = lookup_template(payment_module, 'checkout/empty_cart.html')
            return render_to_response(template, RequestContext(request))
    else:
        return render_to_response('checkout/empty_cart.html', RequestContext(request))
    #Verify order info is here
    if request.POST:
        new_data = request.POST.copy()
        form = CreditPayShipForm(request, payment_module, new_data)
        if form.is_valid():
            data = form.cleaned_data

            # Create a new order
            newOrder = Order(contact=contact)
            pay_ship_save(newOrder, tempCart, contact,
                shipping=data['shipping'], discount=data['discount'])
            request.session['orderID'] = newOrder.id

            #TODO: allow partial-pay here, which will mean that not all payments are on new orders.
            orderpayment = OrderPayment(order=newOrder, amount=newOrder.balance,
                payment=unicode(payment_module.KEY.value))
            orderpayment.save()
            # Save the credit card information
            cc = CreditCardDetail(orderpayment=orderpayment, ccv=data['ccv'],
                expireMonth=data['month_expires'],
                expireYear=data['year_expires'],
                creditType=data['credit_type'])
            cc.storeCC(data['credit_number'])
            cc.save()

            url = lookup_url(payment_module, 'satchmo_checkout-step3')
            return http.HttpResponseRedirect(url)
    else:
        form = CreditPayShipForm(request, payment_module)

    template = lookup_template(payment_module, 'checkout/pay_ship.html')
    ctx = {
        'form' : form,
        'PAYMENT_LIVE' : payment_live(payment_module)
    }
    return render_to_response(template, ctx, RequestContext(request))
Ejemplo n.º 2
0
 def save(self, request, cart, contact, payment_module):
     """Save the order and the credit card information for this orderpayment"""
     super(CreditPayShipForm, self).save(request, cart, contact, payment_module)
     data = self.cleaned_data
     cc = CreditCardDetail(orderpayment=self.orderpayment,
         expire_month=data['month_expires'],
         expire_year=data['year_expires'],
         credit_type=data['credit_type'])
         
     cc.storeCC(data['credit_number'])
     cc.save()
     
     # set ccv into cache
     cc.ccv = data['ccv']
     self.cc = cc
     signals.form_save.send(CreditPayShipForm, form=self)
Ejemplo n.º 3
0
    def save(self, request, cart, contact, payment_module):
        """Save the order and the credit card information for this orderpayment"""
        super(CreditPayShipForm, self).save(request, cart, contact,
                                            payment_module)
        data = self.cleaned_data
        cc = CreditCardDetail(orderpayment=self.orderpayment,
                              expire_month=data['month_expires'],
                              expire_year=data['year_expires'],
                              credit_type=data['credit_type'])

        cc.storeCC(data['credit_number'])
        cc.save()

        # set ccv into cache
        cc.ccv = data['ccv']
        self.cc = cc
        signals.form_save.send(CreditPayShipForm, form=self)