--- /dev/null
+# Generated by Django 2.2.27 on 2022-04-20 23:09
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('club', '0038_payuorder_created_at'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='payuorder',
+ name='status',
+ field=models.CharField(blank=True, choices=[('PENDING', 'Pending'), ('WAITING_FOR_CONFIRMATION', 'Waiting for confirmation'), ('COMPLETED', 'Completed'), ('CANCELED', 'Canceled'), ('REJECTED', 'Rejected'), ('ERR-INVALID_TOKEN', 'Invalid token')], max_length=128),
+ ),
+ ]
if self.status == 'COMPLETED':
self.schedule.set_payed()
- elif self.status == 'CANCELED':
+ elif self.status == 'CANCELED' or self.status.startswith('ERR-'):
if self.is_recurring() and self.schedule.expires_at:
self.schedule.send_email_failed_recurring()
('COMPLETED', _('Completed')),
('CANCELED', _('Canceled')),
('REJECTED', _('Rejected')),
+
+ ('ERR-INVALID_TOKEN', _('Invalid token')),
])
created_at = models.DateTimeField(null=True, blank=True, auto_now_add=True)
completed_at = models.DateTimeField(null=True, blank=True)
# else?
if 'orderId' not in response:
- raise ValueError("Expecting dict with `orderId` key, got: %s" % response)
- self.order_id = response['orderId']
- self.save()
+ code = response.get('status', {}).get('codeLiteral', '')
+ if code:
+ self.status = 'ERR-' + str(code)
+ self.save()
+ self.status_updated()
+ else:
+ raise ValueError("Expecting dict with `orderId` key, got: %s" % response)
+ else:
+ self.order_id = response['orderId']
+ self.save()
-
return response.get('redirectUri', self.schedule.get_thanks_url())