diff options
| author | Baptiste Mispelon <bmispelon@gmail.com> | 2025-01-29 20:56:09 +0100 |
|---|---|---|
| committer | Baptiste Mispelon <bmispelon@gmail.com> | 2025-01-29 21:05:40 +0100 |
| commit | 20507f9a286745ca05788367132236d81af2e931 (patch) | |
| tree | 0aad8fd0f483ddbd99b16c6ebcfad60c5db4aeb1 /fundraising | |
| parent | 6041313005059a41c9f22a27f3a2dbb047c9e8a2 (diff) | |
Fixed stripe API usage in update_card view
Refs #1912
Diffstat (limited to 'fundraising')
| -rw-r--r-- | fundraising/views.py | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/fundraising/views.py b/fundraising/views.py index 4cf2cf9b..39b5d429 100644 --- a/fundraising/views.py +++ b/fundraising/views.py @@ -156,13 +156,10 @@ def manage_donations(request, hero): def update_card(request): donation = get_object_or_404(Donation, id=request.POST["donation_id"]) try: - customer = stripe.Customer.retrieve( - donation.stripe_customer_id, expand=["subscriptions"] + stripe.Customer.modify( + donation.stripe_customer_id, + source=request.POST["stripe_token"], ) - token = stripe.Token.retrieve(request.POST["stripe_token"]) - subscription = customer.subscriptions.retrieve(donation.stripe_subscription_id) - subscription.default_source = token.card.id - subscription.save() except stripe.error.StripeError as e: data = {"success": False, "error": str(e)} else: |
