X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/f1ca816d6a3c478d7d0f8018a57aa6b8a0762201..72fe2a679f27d81c92c65cf005ebf13fae7c7e34:/src/club/management/commands/payu_fake_notify.py diff --git a/src/club/management/commands/payu_fake_notify.py b/src/club/management/commands/payu_fake_notify.py new file mode 100644 index 000000000..a216ac5b7 --- /dev/null +++ b/src/club/management/commands/payu_fake_notify.py @@ -0,0 +1,25 @@ +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +import json +from django.core.management.base import BaseCommand +from club.models import PayUOrder + + +class Command(BaseCommand): + def add_arguments(self, parser): + parser.add_argument('--rejected', '-r', type=bool, default=False) + parser.add_argument('order_id', type=int) + + def handle(self, **options): + order = PayUOrder.objects.get(id=options['order_id']) + status = 'REJECTED' if options['rejected'] else 'COMPLETED' + notification = order.notification_set.create( + body=json.dumps({ + 'order': { + 'status': status, + 'fake': True, + } + }) + ) + notification.apply()