diff --git a/apps/payment/management/__init__.py b/apps/payment/management/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/apps/payment/management/commands/__init__.py b/apps/payment/management/commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/apps/payment/management/commands/roistat_set_statuses.py b/apps/payment/management/commands/roistat_set_statuses.py new file mode 100644 index 00000000..f3ac3e11 --- /dev/null +++ b/apps/payment/management/commands/roistat_set_statuses.py @@ -0,0 +1,50 @@ +import requests + +from paymentwall import Pingback + +from django.conf import settings +from django.core.management.base import BaseCommand, CommandError + + +class Command(BaseCommand): + help = 'Update statuses on Roistat' + + def handle(self, *args, **options): + body = [ + { + 'id': str(Pingback.PINGBACK_TYPE_REGULAR), + 'name': 'PINGBACK_TYPE_REGULAR', + 'type': 'paid', + }, + { + 'id': str(Pingback.PINGBACK_TYPE_GOODWILL), + 'name': 'PINGBACK_TYPE_GOODWILL', + 'type': 'paid', + }, + { + 'id': str(Pingback.PINGBACK_TYPE_NEGATIVE), + 'name': 'PINGBACK_TYPE_NEGATIVE', + 'type': 'canceled', + }, + { + 'id': str(Pingback.PINGBACK_TYPE_RISK_UNDER_REVIEW), + 'name': 'PINGBACK_TYPE_RISK_UNDER_REVIEW', + 'type': 'progress', + }, + { + 'id': str(Pingback.PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED), + 'name': 'PINGBACK_TYPE_RISK_REVIEWED_ACCEPTED', + 'type': 'paid', + }, + { + 'id': str(Pingback.PINGBACK_TYPE_RISK_REVIEWED_DECLINED), + 'name': 'PINGBACK_TYPE_RISK_REVIEWED_DECLINED', + 'type': 'canceled', + }, + ] + project = settings.ROISTAT_PROJECT + key = settings.ROISTAT_KEY + url = settings.ROISTAT_API_URL + f'/project/set-statuses?key={key}&project={project}' + resp = requests.post(url, json=body) + self.stdout.write(str(resp)) + self.stdout.write(str(resp.json()))