Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add DjangoJSONEncoder to Transaction gateway_response JSONField

Michał Jelonek339aafdf3358
diff --git a/saleor/payment/migrations/0005_auto_20181212_0551.py b/saleor/payment/migrations/0005_auto_20181212_0551.py
new file mode 100644
index 0000000000..ffd1619b5b
--- /dev/null
+++ b/saleor/payment/migrations/0005_auto_20181212_0551.py
@@ -0,0 +1,20 @@
+# Generated by Django 2.1.3 on 2018-12-12 11:51
+
+import django.contrib.postgres.fields.jsonb
+import django.core.serializers.json
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('payment', '0004_auto_20181206_0031'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='transaction',
+ name='gateway_response',
+ field=django.contrib.postgres.fields.jsonb.JSONField(encoder=django.core.serializers.json.DjangoJSONEncoder),
+ ),
+ ]
diff --git a/saleor/payment/models.py b/saleor/payment/models.py
index 8a53404ac2..26a0aa8944 100644
--- a/saleor/payment/models.py
+++ b/saleor/payment/models.py
@@ -4,6 +4,7 @@ from operator import attrgetter
from django.conf import settings
from django.contrib.postgres.fields import JSONField
from django.core.validators import MaxValueValidator, MinValueValidator
+from django.core.serializers.json import DjangoJSONEncoder
from django.db import models
from prices import Money
@@ -214,7 +215,7 @@ class Transaction(models.Model):
error = models.CharField(
choices=[(tag, tag.value) for tag in TransactionError],
max_length=256, null=True)
- gateway_response = JSONField()
+ gateway_response = JSONField(encoder=DjangoJSONEncoder)
def __repr__(self):
return 'Transaction(type=%s, is_success=%s, created=%s)' % (