Skip to content

Commit

Permalink
add more thorough has attribute checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Moggach committed Jul 18, 2024
1 parent 248331a commit 36ca2af
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/utils/stripe.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,11 @@ def create_gift_recipient_subscription(
promo_code = stripe.PromotionCode.retrieve(
promo_code_id, expand=["coupon.applies_to"]
)
if hasattr(promo_code.coupon, 'applies_to') and product_id in promo_code.coupon.applies_to.products:
# the gift card is fit for purpose
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
): # the gift card is fit for purpose
discount_args = {"promotion_code": promo_code_id}

else:
Expand Down

0 comments on commit 36ca2af

Please sign in to comment.