From 0147465f7b53db8bd157cdf8d6a086662fb34aa7 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Tue, 27 Dec 2016 16:29:35 +0100 Subject: Some Trustly notifications can show up with no amount --- .../trustlypayment/migrations/0002_nullamount.py | 19 +++++++++++++++++++ postgresqleu/trustlypayment/models.py | 2 +- postgresqleu/trustlypayment/util.py | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 postgresqleu/trustlypayment/migrations/0002_nullamount.py (limited to 'postgresqleu') diff --git a/postgresqleu/trustlypayment/migrations/0002_nullamount.py b/postgresqleu/trustlypayment/migrations/0002_nullamount.py new file mode 100644 index 00000000..efda322d --- /dev/null +++ b/postgresqleu/trustlypayment/migrations/0002_nullamount.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('trustlypayment', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='trustlynotification', + name='amount', + field=models.DecimalField(null=True, max_digits=20, decimal_places=2, blank=True), + ), + ] diff --git a/postgresqleu/trustlypayment/models.py b/postgresqleu/trustlypayment/models.py index d64fa460..13dc54c2 100644 --- a/postgresqleu/trustlypayment/models.py +++ b/postgresqleu/trustlypayment/models.py @@ -26,7 +26,7 @@ class TrustlyNotification(models.Model): notificationid = models.BigIntegerField(null=False, blank=False) orderid = models.BigIntegerField(null=False, blank=False) method = models.CharField(max_length=80, null=False, blank=False) - amount = models.DecimalField(decimal_places=2, max_digits=20, null=False) + amount = models.DecimalField(decimal_places=2, max_digits=20, null=True, blank=True) messageid = models.CharField(max_length=80, null=False, blank=False) confirmed = models.BooleanField(null=False, default=False) diff --git a/postgresqleu/trustlypayment/util.py b/postgresqleu/trustlypayment/util.py index 702ac511..7fdbdb06 100644 --- a/postgresqleu/trustlypayment/util.py +++ b/postgresqleu/trustlypayment/util.py @@ -50,7 +50,7 @@ class Trustly(TrustlyWrapper): method=method, notificationid=data['notificationid'], orderid=data['orderid'], - amount=Decimal(data['amount']), + amount=data.has_key('amount') and Decimal(data['amount']) or None, messageid=data['messageid'], ) n.save() -- cgit v1.2.3