From d3731c54cc883d0fd926fb028564be0a2042b247 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 22 Nov 2017 16:33:13 +0100 Subject: [PATCH] Add Charge.outcome --- pinax/stripe/actions/charges.py | 1 + .../stripe/migrations/0013_charge_outcome.py | 21 +++++++++++++++++++ pinax/stripe/models.py | 1 + pinax/stripe/tests/test_actions.py | 1 + 4 files changed, 24 insertions(+) create mode 100644 pinax/stripe/migrations/0013_charge_outcome.py diff --git a/pinax/stripe/actions/charges.py b/pinax/stripe/actions/charges.py index ee0857403..5e267134c 100644 --- a/pinax/stripe/actions/charges.py +++ b/pinax/stripe/actions/charges.py @@ -203,6 +203,7 @@ def sync_charge_from_stripe_data(data): ) obj.fee_currency = balance_transaction["currency"] obj.transfer_group = data.get("transfer_group") + obj.outcome = data.get("outcome") obj.save() return obj diff --git a/pinax/stripe/migrations/0013_charge_outcome.py b/pinax/stripe/migrations/0013_charge_outcome.py new file mode 100644 index 000000000..bcb9183e8 --- /dev/null +++ b/pinax/stripe/migrations/0013_charge_outcome.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.6 on 2017-11-22 15:40 +from __future__ import unicode_literals + +from django.db import migrations +import jsonfield.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('pinax_stripe', '0014_blank_with_null'), + ] + + operations = [ + migrations.AddField( + model_name='charge', + name='outcome', + field=jsonfield.fields.JSONField(blank=True, null=True), + ), + ] diff --git a/pinax/stripe/models.py b/pinax/stripe/models.py index 29489307b..6b57d67f6 100644 --- a/pinax/stripe/models.py +++ b/pinax/stripe/models.py @@ -468,6 +468,7 @@ class Charge(StripeAccountFromCustomerMixin, StripeObject): fee_currency = models.CharField(max_length=10, null=True, blank=True) transfer_group = models.TextField(null=True, blank=True) + outcome = JSONField(null=True, blank=True) objects = ChargeManager() diff --git a/pinax/stripe/tests/test_actions.py b/pinax/stripe/tests/test_actions.py index f8b3bcf44..11ed7ce27 100644 --- a/pinax/stripe/tests/test_actions.py +++ b/pinax/stripe/tests/test_actions.py @@ -2155,6 +2155,7 @@ def test_sync_charge_from_stripe_data_failed(self): charge = Charge.objects.get(stripe_id=data["id"]) self.assertEqual(charge.amount, decimal.Decimal("2")) self.assertEqual(charge.customer, None) + self.assertEqual(charge.outcome["risk_level"], "normal") @patch("stripe.Subscription.retrieve") def test_retrieve_stripe_subscription(self, RetrieveMock):