diff options
| author | Baptiste Mispelon <bmispelon@gmail.com> | 2025-01-28 20:48:50 +0100 |
|---|---|---|
| committer | Baptiste Mispelon <bmispelon@gmail.com> | 2025-01-28 21:05:03 +0100 |
| commit | 6cd88270b5a94485c8cf22eda7bba7cee65332e7 (patch) | |
| tree | 3613c85c505823c7fb26749837a8d02b3d45fb72 /fundraising | |
| parent | 9b386bb49bc8abf1501e80b090211c89a9966b17 (diff) | |
Fixed more stripe crashes in fundraising views
Ideally this would have been done in 675ed458602bf2492efceec0431ca919739c8c09
but I didn't notice it then...
Should fix #1912
Diffstat (limited to 'fundraising')
| -rw-r--r-- | fundraising/tests/test_views.py | 2 | ||||
| -rw-r--r-- | fundraising/views.py | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/fundraising/tests/test_views.py b/fundraising/tests/test_views.py index 37b27909..2e2a4415 100644 --- a/fundraising/tests/test_views.py +++ b/fundraising/tests/test_views.py @@ -149,7 +149,7 @@ class TestCampaign(TemporaryMediaRootMixin, TestCase): self.assertRedirects( response, reverse("fundraising:manage-donations", kwargs={"hero": donor.id}) ) - retrieve_customer.assert_called_once_with("54321") + retrieve_customer.assert_called_once_with("54321", expand=["subscriptions"]) donation = Donation.objects.get(id=donation.id) self.assertEqual("", donation.stripe_subscription_id) diff --git a/fundraising/views.py b/fundraising/views.py index 378724da..9a8fe071 100644 --- a/fundraising/views.py +++ b/fundraising/views.py @@ -160,7 +160,7 @@ def update_card(request): donation.stripe_customer_id, expand=["subscriptions"] ) subscription = customer.subscriptions.retrieve(donation.stripe_subscription_id) - subscription.source = request.POST["stripe_token"] + subscription.default_source = request.POST["stripe_token"] subscription.save() except stripe.error.StripeError as e: data = {"success": False, "error": str(e)} @@ -176,7 +176,9 @@ def cancel_donation(request, hero): donations = hero.donation_set.exclude(stripe_subscription_id="") donation = get_object_or_404(donations, pk=donation_id) - customer = stripe.Customer.retrieve(donation.stripe_customer_id) + customer = stripe.Customer.retrieve( + donation.stripe_customer_id, expand=["subscriptions"] + ) customer.subscriptions.retrieve(donation.stripe_subscription_id).delete() donation.stripe_subscription_id = "" |
