예제 #1
0
    def setUp(self):
        u = User(username='******',
                 email='*****@*****.**',
                 is_active=True)
        u.set_password('johnpassword')
        u.save()
        p = Profile(user=u,
                       campaign_cid='0',
                       sid='0',
                       affiliate='0',
                       phone='(555) 555-5555',
                       shipping_address1="9518 New Waterford Cv",
                       shipping_zip="33446-9747",
                       shipping_state="FL",
                       shipping_city="Delray Beach",
                       shipping_county="Palm Beach",
                       shipping_checksum="0d35b4ffcb260482947680f48ba8e482",
                       )
        p.save()

        billing_card = BillingCard(user=u,
                type="visa",
                display_number="XXXX-XXXX-XXXX-1150",
                data = "XnSDaVgvyOUaZmrftFo0rKPFhyHdf+E6WyMxz45cG6yk4kr6ob0A+6mxnY8Xrf2IMXBEIBrNN7FhvyzpGb77JX0PG1sl8rDKhdPNMsa8xBt9pzVee9nsUXm3GYo2VRLpGLPrRoBphEPkdnGw",
                first_name="Mvi",
                last_name="Mvi",
                address1="9518 New Waterford Cv",
                address2="",
                city="Delray Beach",
                state="FL",
                county="Palm Beach",
                zip="33446-9747",
                checksum="670bee769cd1e3644e411110a6b32dd4",
                address_checksum="3e3c98e96e4dd335c59629b323892b5a"
        )
        billing_card.save()
        self.user = u
        self.game_item = Item.objects.get(pk=100000077)
        #creating a distributor and an entry in stock for this game
        self.fake_distributor = Distributor(id=5,name='fake distributor', address='fake address',new_games_vendor=True)
        self.fake_distributor.save()
        self.game_distributor_item = DistributorItem(distributor=self.fake_distributor,
            item=self.game_item,
            is_new=True,
            retail_price=Decimal('18.99'),
            wholesale_price=Decimal('18.99'),
            quantity=50,
            profit=1,
            retail_price_used_vendor=Decimal('11.99'),
            wholesale_price_used=Decimal('11.99'),
            quantity_used=10,
            trade_price=Decimal('11.99'),
            trade_price_incomplete=Decimal('5.99')
        )
        self.game_distributor_item.save()
예제 #2
0
 def save(self, request, entry_point=ProfileEntryPoint.Direct):
     email = self.cleaned_data.get('email')
     password = self.cleaned_data.get('password')
     username = self.cleaned_data.get('username')
     phone_number = self.cleaned_data.get('phone_number')
     u = User(username=username,
              email=email,
              is_active=False)
     u.set_password(password)
     u.save()
     p = Profile.create(request, u, entry_point=entry_point, phone=phone_number)
     p.save()
     p.send_email_confirmation_mail()
     return u
예제 #3
0
    def done(self, request, form_list):
        profile_form = form_list[0].cleaned_data
        billing_form = form_list[1].cleaned_data

        u = User(username=profile_form['username'], email=profile_form['email'], is_active=False)
        u.set_password(profile_form['password'])
        u.save()
        if u:
            p = Profile.create(request, u, entry_point=ProfileEntryPoint.Trade)
            p.set_name_data(form_list[0].cached_name)
            p.set_shipping_address_data(form_list[0].cached_address)
            p.set_billing_name_data(form_list[1].cached_name, False)
            p.set_billing_address_data(form_list[1].cached_address, False)
            p.set_billing_card_data(billing_form, True)
            p.send_email_confirmation_mail()

        res = {}
        res['close'] = True
        res['redirect_to'] = reverse('members:create_account_complete')
        return JsonResponse(res)
예제 #4
0
    def done(self, request, form_list):
        data = form_list[0].cleaned_data

        _user = User(username=data['username'], email=data['email'], is_active=False)
        _user.set_password(data['password'])
        _user.save()
        if _user:
            _profile = Profile.create(
                request, _user, entry_point=self.entry_point or ProfileEntryPoint.Direct)
            _profile.how_did_you_hear = data['how_did_you_hear']
            _profile.set_name_data(form_list[0].cached_name)
            _profile.send_email_confirmation_mail()

        template_name = 'members/wizards/signup.dialog.html'
        result = loader.render_to_string(template_name, {
                'title': 'Profile Information',
                'step': 2,
                'step_count': 1,
                'email': data['email'],
            }, context_instance=RequestContext(request))
        content = json.dumps({'form': result})
        return HttpResponse(content, mimetype='application/json')
예제 #5
0
 def save(self, request, entry_point=ProfileEntryPoint.DeckTheHalls):
     email = self.cleaned_data.get('email')
     password = self.cleaned_data.get('password')
     username = self.cleaned_data.get('username')
     if settings.MELISSA:
         full_name = self.cleaned_data.get('first_name') + ' ' + self.cleaned_data.get('last_name')
         full_name = settings.MELISSA.inaccurate_name(full_name=full_name)
         first_name = full_name['first_name']
         last_name = full_name['last_name']
     else:
         first_name = self.cleaned_data.get('first_name')
         last_name = self.cleaned_data.get('last_name')
     u = User(username=username,
              email=email,
              is_active=False,
              first_name=first_name,
              last_name=last_name)
     u.set_password(password)
     u.save()
     p = Profile.create(request, u, entry_point=entry_point)
     p.save()
     p.send_email_confirmation_mail()
     return u
예제 #6
0
    def clean(self):
        data = super(CheckoutForm, self).clean(skip_card_verification=True)
        if not self._errors:
            request = self.request
            user = request.user
            if not user.is_authenticated():
                p = Profile.create(request, None, entry_point=ProfileEntryPoint.Buy)
            else:
                p = user.get_profile()
    
            self.profile = p
                
            order_data = {
                'card_display_number': self.cached_card['display_number'],
                'card_data': self.cached_card['data'],
                'card_type': self.cached_card['type'], 
                'billing_state': self.cached_address['state'],
                'billing_county': self.cached_address.get('county'),}
            
            self.order = BuyOrder.create(request, order_data, p)

            wizard = self.request.checkout_wizard
            f = wizard.get_form(0, self.request.POST)
            f.is_valid() # it's a long way to get info from here
            email = user.email if user.is_authenticated() else f.cleaned_data['email']
            shipping_address = f.cached_address
            shipping_address.update(f.cached_name)
            shipping_address['country'] = 'USA'
            billing_address = self.cached_address
            billing_address.update(self.cached_name)
            billing_address['country'] = 'USA'
            
            self.billing_history = BillingHistory.create(user if user.is_authenticated() else None,
                order_data['card_display_number'], debit=self.order.get_order_total(),
                description = 'Shop Order #%s' % self.order.get_order_number(), 
                reason='buy', type=TransactionType.BuyCheckout)

            if self.order.user:
                invoice_num = 'BUY_%s_%s' % (self.order.user.id, self.billing_history.id)
            else:
                invoice_num = 'BUY_%s' % self.billing_history.id
            
            card = self.cached_card['data']
            aim_data = {
                'number': card['number'], 
                'exp': '/'.join((card['exp_month'], card['exp_year'][-2:])), 
                'code': card['code'],
                'billing': billing_address, 
                'shipping': shipping_address, 
                'invoice_num': invoice_num, 
                'description': self.order.get_aim_description(),
                'x_customer_ip': self.request.META.get('REMOTE_ADDR'),
                'x_email': email,
                'x_po_num': self.order.order_no(),
            }
            if p.user:
                aim_data['x_cust_id'] = p.user.id
            
            self.billing_history.tax = self.order.get_tax_amount()
            self.billing_history.applied_credits = self.order.applied_credits
            aim_data['x_tax'] = self.billing_history.tax 

            self.billing_history.aim_transaction_id = self.order.take_charge(aim_data) 
            
            if self.billing_history.aim_transaction_id or not self.order.get_charge_amount():
                self.billing_history.card_data = self.cached_card['data']
                self.billing_history.save()
                self.order.payment_transaction = self.billing_history
                self.order.save() 
                request.cart.empty()
            else:
                msg = self.order.message
                self.order.delete()
                if p.user:
                    self.billing_history.status = TransactionStatus.Declined
                    self.billing_history.save()
                else:
                    self.billing_history.delete()
                raise forms.ValidationError(msg)
        return data