예제 #1
0
    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)
예제 #2
0
    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)
예제 #3
0
 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()