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
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/utils/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,14 +340,14 @@ def create_gift_recipient_subscription(
promo_code = stripe.PromotionCode.retrieve(
promo_code_id, expand=["coupon.applies_to"]
)
if product_id in promo_code.coupon.applies_to.products:
# the gift card is fit for purpose
if hasattr(promo_code.coupon, 'applies_to') and product_id in promo_code.coupon.applies_to.products:
# the gift card is fit for purpose
discount_args = {"promotion_code": promo_code_id}

else:
# if they're in this situation of the gift card being for an old product
# get the right coupon for the target product
# if they're in this situation of the gift card being for an old product
# get the right coupon for the target product
coupon = get_gift_card_coupon(product_id)

# invalidate the gift card's promo code so it can't be used again
promo_code = stripe.PromotionCode.modify(promo_code_id, active=False)

Expand Down
Loading