parent
f27df06691
commit
858f9f9064
2 changed files with 36 additions and 2 deletions
@ -0,0 +1,34 @@ |
||||
from django.core.management.base import BaseCommand, CommandError |
||||
from django.utils.timezone import now |
||||
from paymentwall.pingback import Pingback |
||||
|
||||
from apps.payment.tasks import transaction_to_roistat |
||||
from apps.payment.models import Payment |
||||
|
||||
|
||||
class Command(BaseCommand): |
||||
help = 'Send ' |
||||
|
||||
def add_arguments(self, parser): |
||||
parser.add_argument( |
||||
'start_id', type=int, |
||||
help='Start payment id', |
||||
) |
||||
|
||||
def handle(self, *args, **options): |
||||
start_id = options.get('start_id') |
||||
payments = Payment.objects.filter(id__gte=start_id, status__in=Payment.PW_PAID_STATUSES) |
||||
for payment in payments: |
||||
pingback = Pingback(payment.data) |
||||
splitted = pingback.get_product().get_id().split('_') |
||||
product_type_name, payment_id = '_'.join(splitted[:-1]), splitted[-1] |
||||
transaction_to_roistat.delay( |
||||
payment.user.id, |
||||
payment.id, |
||||
f'{product_type_name.title()} payment', |
||||
payment.amount, |
||||
now().strftime('%Y-%m-%d %H:%M:%S'), |
||||
pingback.get_type(), |
||||
product_type_name, |
||||
payment.roistat_visit, |
||||
) |
||||
Loading…
Reference in new issue