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()
def handle_noargs(self, **options): for o in BuyOrder.objects.filter(payment_transaction__status__in=[TransactionStatus.Passed, TransactionStatus.Authorized]).exclude(status=BuyOrderStatus.Checkout): print o.id o.status = BuyOrderStatus.Checkout o.first_name = o.user.first_name o.last_name = o.user.last_name o.shipping_address1 = o.user.profile.shipping_address1 o.shipping_address2 = o.user.profile.shipping_address2 o.shipping_city = o.user.profile.shipping_city o.shipping_state = o.user.profile.shipping_state o.shipping_county = o.user.profile.shipping_county o.shipping_zip_code = o.user.profile.shipping_zip cc = BillingCard.get(o.user) o.billing_first_name = cc.first_name o.billing_last_name = cc.last_name o.billing_address1 = cc.address1 o.billing_address2 = cc.address2 o.billing_city = cc.city o.billing_state = cc.state o.billing_county = cc.county o.billing_zip_code = cc.zip o.save() o.complete(True)
def take_recurring_billing(self, aim_method="capture"): from project.new_rent.models import RentalPlan if self.next_payment_type == "AUTH_ONLY": aim_method = "authorize" elif self.next_payment_type == "PRIOR_AUTH_CAPTURE": success, res = self.get_last_payment().capture() if not success: if (res.aim_response.get("response_code") == 3 and res.aim_response.get("response_reason_code") in [6, 7, 8]): self.card_expired = True msg = 'Credit card is expired' elif res.aim_response.get("response_reason_code") in [2, 3, 4]: msg = 'Insufficient funds are available for this transaction.' elif res.aim_response.get("avs_response") == 'U': msg = 'We do not accept prepaid cards.' else: msg = 'We are unable to process you credit card at this time.' self.set_status(RentalPlanStatus.Delinquent, msg) self.send_recurring_billing_charge_declined(1) return False (self.next_payment_date, self.next_payment_amount, _) = RentalPlan.objects.get(pk=self.plan).get_next_payment(datetime.date.today()) self.next_payment_type = "AUTH_CAPTURE" self.save() billing_card = BillingCard.get(self.user) if res.debit > 0: self.send_billing_charge_approved( billing_card.get_type_display(), billing_card.display_number, res.debit) self.user.get_profile().clear_locked_store_credits() self.set_status(RentalPlanStatus.Active) return True return OldMemberRentalPlan.__dict__["take_recurring_billing"]( self, aim_method)
def do_fix(self): for member_plan in MemberRentalPlan.objects.filter(): cc = BillingCard.get(member_plan.user) if isinstance(cc.data, str): cc.data = None cc.save()