forked from uncloud/uncloud
Pay: move some model-related methods from helpers to models
Otherwise we end up in circular dependency hell
This commit is contained in:
parent
e0cb6ac670
commit
9aabc66e57
6 changed files with 108 additions and 107 deletions
|
|
@ -1,7 +1,6 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from uncloud_auth.models import User
|
||||
from uncloud_pay.models import Order, Bill
|
||||
from uncloud_pay.helpers import get_balance_for, get_payment_method_for
|
||||
from uncloud_pay.models import Order, Bill, PaymentMethod, get_balance_for
|
||||
|
||||
from datetime import timedelta
|
||||
from django.utils import timezone
|
||||
|
|
@ -19,7 +18,7 @@ class Command(BaseCommand):
|
|||
balance = get_balance_for(user)
|
||||
if balance < 0:
|
||||
print("User {} has negative balance ({}), charging.".format(user.username, balance))
|
||||
payment_method = get_payment_method_for(user)
|
||||
payment_method = PaymentMethod.get_primary_for(user)
|
||||
if payment_method != None:
|
||||
amount_to_be_charged = abs(balance)
|
||||
charge_ok = payment_method.charge(amount_to_be_charged)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue