mirror of
https://github.com/simple-login/app.git
synced 2024-09-28 20:51:29 +02:00
add more logging
This commit is contained in:
parent
2ad1b75e45
commit
7ab64d9768
@ -38,7 +38,9 @@ def billing():
|
|||||||
return redirect(url_for("dashboard.billing"))
|
return redirect(url_for("dashboard.billing"))
|
||||||
elif request.form.get("form-name") == "change-monthly":
|
elif request.form.get("form-name") == "change-monthly":
|
||||||
LOG.debug(f"User {current_user} changes to monthly plan")
|
LOG.debug(f"User {current_user} changes to monthly plan")
|
||||||
success, msg = change_plan(sub.subscription_id, PADDLE_MONTHLY_PRODUCT_ID)
|
success, msg = change_plan(
|
||||||
|
current_user, sub.subscription_id, PADDLE_MONTHLY_PRODUCT_ID
|
||||||
|
)
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
sub.plan = PlanEnum.monthly
|
sub.plan = PlanEnum.monthly
|
||||||
@ -57,7 +59,9 @@ def billing():
|
|||||||
return redirect(url_for("dashboard.billing"))
|
return redirect(url_for("dashboard.billing"))
|
||||||
elif request.form.get("form-name") == "change-yearly":
|
elif request.form.get("form-name") == "change-yearly":
|
||||||
LOG.debug(f"User {current_user} changes to yearly plan")
|
LOG.debug(f"User {current_user} changes to yearly plan")
|
||||||
success, msg = change_plan(sub.subscription_id, PADDLE_YEARLY_PRODUCT_ID)
|
success, msg = change_plan(
|
||||||
|
current_user, sub.subscription_id, PADDLE_YEARLY_PRODUCT_ID
|
||||||
|
)
|
||||||
|
|
||||||
if success:
|
if success:
|
||||||
sub.plan = PlanEnum.yearly
|
sub.plan = PlanEnum.yearly
|
||||||
|
@ -19,6 +19,7 @@ from app.config import PADDLE_PUBLIC_KEY_PATH, PADDLE_VENDOR_ID, PADDLE_AUTH_COD
|
|||||||
|
|
||||||
# Your Paddle public key.
|
# Your Paddle public key.
|
||||||
from app.log import LOG
|
from app.log import LOG
|
||||||
|
from app.models import User
|
||||||
|
|
||||||
with open(PADDLE_PUBLIC_KEY_PATH) as f:
|
with open(PADDLE_PUBLIC_KEY_PATH) as f:
|
||||||
public_key = f.read()
|
public_key = f.read()
|
||||||
@ -78,7 +79,7 @@ def cancel_subscription(subscription_id: int) -> bool:
|
|||||||
return res["success"]
|
return res["success"]
|
||||||
|
|
||||||
|
|
||||||
def change_plan(subscription_id: str, plan_id) -> (bool, str):
|
def change_plan(user: User, subscription_id: str, plan_id) -> (bool, str):
|
||||||
"""return whether the operation is successful and an optional error message"""
|
"""return whether the operation is successful and an optional error message"""
|
||||||
r = requests.post(
|
r = requests.post(
|
||||||
"https://vendors.paddle.com/api/2.0/subscription/users/update",
|
"https://vendors.paddle.com/api/2.0/subscription/users/update",
|
||||||
@ -94,6 +95,11 @@ def change_plan(subscription_id: str, plan_id) -> (bool, str):
|
|||||||
try:
|
try:
|
||||||
# "unable to complete the resubscription because we could not charge the customer for the resubscription"
|
# "unable to complete the resubscription because we could not charge the customer for the resubscription"
|
||||||
if res["error"]["code"] == 147:
|
if res["error"]["code"] == 147:
|
||||||
|
LOG.w(
|
||||||
|
"could not charge the customer for the resubscription error %s,%s",
|
||||||
|
subscription_id,
|
||||||
|
user,
|
||||||
|
)
|
||||||
return False, "Your card cannot be charged"
|
return False, "Your card cannot be charged"
|
||||||
except KeyError:
|
except KeyError:
|
||||||
LOG.exception(
|
LOG.exception(
|
||||||
|
Loading…
Reference in New Issue
Block a user