Skip to content

Commit 6cd8827

Browse files
committed
Fixed more stripe crashes in fundraising views
Ideally this would have been done in 675ed45 but I didn't notice it then... Should fix #1912
1 parent 9b386bb commit 6cd8827

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

fundraising/tests/test_views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def test_cancel_donation(self, retrieve_customer):
149149
self.assertRedirects(
150150
response, reverse("fundraising:manage-donations", kwargs={"hero": donor.id})
151151
)
152-
retrieve_customer.assert_called_once_with("54321")
152+
retrieve_customer.assert_called_once_with("54321", expand=["subscriptions"])
153153
donation = Donation.objects.get(id=donation.id)
154154
self.assertEqual("", donation.stripe_subscription_id)
155155

fundraising/views.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def update_card(request):
160160
donation.stripe_customer_id, expand=["subscriptions"]
161161
)
162162
subscription = customer.subscriptions.retrieve(donation.stripe_subscription_id)
163-
subscription.source = request.POST["stripe_token"]
163+
subscription.default_source = request.POST["stripe_token"]
164164
subscription.save()
165165
except stripe.error.StripeError as e:
166166
data = {"success": False, "error": str(e)}
@@ -176,7 +176,9 @@ def cancel_donation(request, hero):
176176
donations = hero.donation_set.exclude(stripe_subscription_id="")
177177
donation = get_object_or_404(donations, pk=donation_id)
178178

179-
customer = stripe.Customer.retrieve(donation.stripe_customer_id)
179+
customer = stripe.Customer.retrieve(
180+
donation.stripe_customer_id, expand=["subscriptions"]
181+
)
180182
customer.subscriptions.retrieve(donation.stripe_subscription_id).delete()
181183

182184
donation.stripe_subscription_id = ""

0 commit comments

Comments
 (0)