djaodjin / djaodjin-saas

Django application for software-as-service and subscription businesses
Other
564 stars 124 forks source link

limit coupon use as one per profile #280

Open smirolo opened 1 year ago

smirolo commented 1 year ago

Right now, it is possible to limit a Coupon in time, plans it applies to and number of times it can be used. Nothing prevents a single profile to use the coupon repetitively, every period for example, until the Coupon is no longer valid.

We would like to restrict the use of a Coupon to "once per subscriber". Based on the code in Transaction.get_event it is possible that per-subscriber coupon use is stored in the Transaction table directly, as much as it is as text in Transaction.descr (see describe_buy_periods). It is not sure though the get_event idea works. Maybe will have to either use a regex on Transaction.descr or use an alternate implementation idea.