mirror of
https://github.com/simple-login/app.git
synced 2025-02-25 00:03:03 +08:00
Support OTHER_PADDLE_MONTHLY_PRODUCT_IDS, OTHER_PADDLE_YEARLY_PRODUCT_IDS config
This commit is contained in:
parent
3f8e5d0a8b
commit
15466903d1
2 changed files with 36 additions and 5 deletions
|
@ -179,6 +179,29 @@ except:
|
|||
PADDLE_MONTHLY_PRODUCT_ID = -1
|
||||
PADDLE_YEARLY_PRODUCT_ID = -1
|
||||
|
||||
# Other Paddle product IDS
|
||||
if "OTHER_PADDLE_MONTHLY_PRODUCT_IDS" in os.environ:
|
||||
OTHER_PADDLE_MONTHLY_PRODUCT_IDS = eval(
|
||||
os.environ["OTHER_PADDLE_MONTHLY_PRODUCT_IDS"]
|
||||
)
|
||||
else:
|
||||
OTHER_PADDLE_MONTHLY_PRODUCT_IDS = []
|
||||
|
||||
PADDLE_MONTHLY_PRODUCT_IDS = OTHER_PADDLE_MONTHLY_PRODUCT_IDS.append(
|
||||
PADDLE_MONTHLY_PRODUCT_ID
|
||||
)
|
||||
|
||||
if "OTHER_PADDLE_YEARLY_PRODUCT_IDS" in os.environ:
|
||||
OTHER_PADDLE_YEARLY_PRODUCT_IDS = eval(
|
||||
os.environ["OTHER_PADDLE_YEARLY_PRODUCT_IDS"]
|
||||
)
|
||||
else:
|
||||
OTHER_PADDLE_YEARLY_PRODUCT_IDS = []
|
||||
|
||||
PADDLE_YEARLY_PRODUCT_IDS = OTHER_PADDLE_YEARLY_PRODUCT_IDS.append(
|
||||
PADDLE_YEARLY_PRODUCT_ID
|
||||
)
|
||||
|
||||
PADDLE_PUBLIC_KEY_PATH = get_abs_path(
|
||||
os.environ.get("PADDLE_PUBLIC_KEY_PATH", "local_data/paddle.key.pub")
|
||||
)
|
||||
|
|
18
server.py
18
server.py
|
@ -50,6 +50,8 @@ from app.config import (
|
|||
STATUS_PAGE_URL,
|
||||
SUPPORT_EMAIL,
|
||||
get_abs_path,
|
||||
PADDLE_MONTHLY_PRODUCT_IDS,
|
||||
PADDLE_YEARLY_PRODUCT_IDS,
|
||||
)
|
||||
from app.dashboard.base import dashboard_bp
|
||||
from app.developer.base import developer_bp
|
||||
|
@ -497,13 +499,19 @@ def setup_paddle_callback(app: Flask):
|
|||
user_id = passthrough.get("user_id")
|
||||
user = User.get(user_id)
|
||||
|
||||
if (
|
||||
int(request.form.get("subscription_plan_id"))
|
||||
== PADDLE_MONTHLY_PRODUCT_ID
|
||||
):
|
||||
subscription_plan_id = int(request.form.get("subscription_plan_id"))
|
||||
|
||||
if subscription_plan_id in PADDLE_MONTHLY_PRODUCT_IDS:
|
||||
plan = PlanEnum.monthly
|
||||
else:
|
||||
elif subscription_plan_id in PADDLE_YEARLY_PRODUCT_IDS:
|
||||
plan = PlanEnum.yearly
|
||||
else:
|
||||
LOG.exception(
|
||||
"Unknown subscription_plan_id %s %s",
|
||||
subscription_plan_id,
|
||||
request.form,
|
||||
)
|
||||
return "No such subscription", 400
|
||||
|
||||
sub = Subscription.get_by(user_id=user.id)
|
||||
|
||||
|
|
Loading…
Reference in a new issue