# Path: payments/models.py
# class Payment(models.Model):
#     """ Just a payment.
#     If subscription is not null, it has been automatically issued.
#     backend_extid is the external transaction ID, backend_data is other
#     things that should only be used by the associated backend.
#     """
#     user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
#     backend_id = models.CharField(max_length=16, choices=BACKEND_CHOICES)
#     status = models.CharField(max_length=16, choices=STATUS_CHOICES, default='new')
#     created = models.DateTimeField(auto_now_add=True)
#     modified = models.DateTimeField(auto_now=True)
#     confirmed_on = models.DateTimeField(null=True, blank=True)
#     amount = models.IntegerField()
#     paid_amount = models.IntegerField(default=0)
#     time = models.DurationField()
#     subscription = models.ForeignKey('Subscription', null=True, blank=True)
#     status_message = models.TextField(blank=True, null=True)
# 
#     backend_extid = models.CharField(max_length=64, null=True, blank=True)
#     backend_data = JSONField(blank=True)
# 
#     @property
#     def currency_code(self):
#         return CURRENCY_CODE
# 
#     @property
#     def currency_name(self):
#         return CURRENCY_NAME
# 
#     @property
#     def backend(self):
#         """ Returns a global instance of the backend
#         :rtype: BackendBase
#         """
#         return BACKENDS[self.backend_id]
# 
#     def get_amount_display(self):
#         return '%.2f %s' % (self.amount / 100, CURRENCY_NAME)
# 
#     @property
#     def is_confirmed(self):
#         return self.status == 'confirmed'
# 
#     class Meta:
#         ordering = ('-created', )
# 
#     @classmethod
#     def create_payment(self, backend_id, user, months):
#         payment = Payment(
#             user=user,
#             backend_id=backend_id,
#             status='new',
#             time=timedelta(days=30 * months),
#             amount=get_price() * months
#         )
#         return payment
# 
# ACTIVE_BACKENDS = {}


from django.core.management.base import BaseCommand, CommandError
from payments.models import Payment, ACTIVE_BACKENDS



class Command(BaseCommand):
    help = "Check bitcoin payments status"

    def handle(self, *args, **options):

# Path: payments/models.py
# class Payment(models.Model):
#     """ Just a payment.
#     If subscription is not null, it has been automatically issued.
#     backend_extid is the external transaction ID, backend_data is other
#     things that should only be used by the associated backend.
#     """
#     user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
#     backend_id = models.CharField(max_length=16, choices=BACKEND_CHOICES)
#     status = models.CharField(max_length=16, choices=STATUS_CHOICES, default='new')
#     created = models.DateTimeField(auto_now_add=True)
#     modified = models.DateTimeField(auto_now=True)
#     confirmed_on = models.DateTimeField(null=True, blank=True)
#     amount = models.IntegerField()
#     paid_amount = models.IntegerField(default=0)
#     time = models.DurationField()
#     subscription = models.ForeignKey('Subscription', null=True, blank=True)
#     status_message = models.TextField(blank=True, null=True)
# 
#     backend_extid = models.CharField(max_length=64, null=True, blank=True)
#     backend_data = JSONField(blank=True)
# 
#     @property
#     def currency_code(self):
#         return CURRENCY_CODE
# 
#     @property
#     def currency_name(self):
#         return CURRENCY_NAME
# 
#     @property
#     def backend(self):
#         """ Returns a global instance of the backend
#         :rtype: BackendBase
#         """
#         return BACKENDS[self.backend_id]
# 
#     def get_amount_display(self):
#         return '%.2f %s' % (self.amount / 100, CURRENCY_NAME)
# 
#     @property
#     def is_confirmed(self):
#         return self.status == 'confirmed'
# 
#     class Meta:
#         ordering = ('-created', )
# 
#     @classmethod
#     def create_payment(self, backend_id, user, months):
#         payment = Payment(
#             user=user,
#             backend_id=backend_id,
#             status='new',
#             time=timedelta(days=30 * months),
#             amount=get_price() * months
#         )
#         return payment
# 
# ACTIVE_BACKENDS = {}


# Path: payments/management/commands/check_btc_payments.py
from django.core.management.base import BaseCommand, CommandError
from payments.models import Payment, ACTIVE_BACKENDS




class Command(BaseCommand):
    help = "Check bitcoin payments status"

    def handle(self, *args, **options):

        if 'bitcoin' not in ACTIVE_BACKENDS: