+ self.report_activity()
+
+ @property
+ def updated_at(self):
+ try:
+ return self.notification_set.all().order_by('-received_at')[0].received_at
+ except IndexError:
+ return None
+
+ def report_activity(self):
+ if self.status not in ['COMPLETED', 'CANCELED', 'REJECTED']:
+ return
+
+ if self.status != 'COMPLETED':
+ name = settings.CIVICRM_ACTIVITIES['Failed contribution']
+ elif self.is_recurring():
+ name = settings.CIVICRM_ACTIVITIES['Recurring contribution']
+ else:
+ name = settings.CIVICRM_ACTIVITIES['Contribution']
+
+ report_activity.delay(
+ self.schedule.email,
+ self.schedule.key,
+ f'payu:{self.id}',
+ name,
+ self.updated_at,
+ {
+ 'kwota': self.schedule.amount,
+ }
+ )