Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug preventing redemption of gift subscriptions #477

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

Moggach
Copy link
Contributor

@Moggach Moggach commented Jul 18, 2024

Description

This PR adds an additional attribute check for applies_to attribute on coupon object returned from Stripe before checking for which products (if any) the coupon applies to.
This prevents the app from crashing due to an attribute error

Motivation and Context

Addresses issue LBC-404

Motivation and Context

Download the branch and run locally
Create a gift subscription using Stripe test cards
Copy gift card code
Sign out and go to http://127.0.0.1:8000/redeem/
Enter the code, create another account and add shipping details
The gift card should be redeemed successfully

How Will This Be Deployed?

Normal deployment process

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Copy link

sentry-io bot commented Jul 18, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: app/utils/mailchimp.py

Function Unhandled Issue
mailchimp_contact_for_user ApiClientError /checkout/{price_id}/{product_id}/
Event Count: 21
📄 File: app/utils/stripe.py (Click to Expand)
Function Unhandled Issue
create_gift_recipient_subscription AttributeError: applies_to /redeem/setup/
Event Count: 5
---

Did you find this useful? React with a 👍 or 👎

@Moggach Moggach changed the base branch from main to production July 18, 2024 14:16
@Moggach Moggach requested a review from joaquimds July 18, 2024 14:16
@joaquimds
Copy link

looks good to me, although you could also add:

if (
  hasattr(promo_code.coupon, 'applies_to') and 
  hasattr(promo_code.coupon.applies_to, 'products') and 
  product_id in promo_code.coupon.applies_to.products
):

@Moggach Moggach merged commit a9b6ca3 into production Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants