diff --git a/app/api/views/apple.py b/app/api/views/apple.py index 0f27696a..9e1559c6 100644 --- a/app/api/views/apple.py +++ b/app/api/views/apple.py @@ -474,7 +474,7 @@ def verify_receipt(receipt_data, user, password) -> Optional[AppleSubscription]: # } if data["status"] != 0: - LOG.w( + LOG.e( "verifyReceipt status !=0, probably invalid receipt. User %s, data %s", user, data, @@ -521,9 +521,10 @@ def verify_receipt(receipt_data, user, password) -> Optional[AppleSubscription]: if apple_sub: LOG.d( - "Update AppleSubscription for user %s, expired at %s, plan %s", + "Update AppleSubscription for user %s, expired at %s (%s), plan %s", user, expires_date, + expires_date.humanize(), plan, ) apple_sub.receipt_data = receipt_data diff --git a/cron.py b/cron.py index 4e5bd4a8..e3a657b4 100644 --- a/cron.py +++ b/cron.py @@ -264,9 +264,15 @@ def poll_apple_subscription(): """Poll Apple API to update AppleSubscription""" # todo: only near the end of the subscription for apple_sub in AppleSubscription.all(): + if not apple_sub.product_id: + LOG.d("Ignore %s", apple_sub) + continue + user = apple_sub.user - verify_receipt(apple_sub.receipt_data, user, APPLE_API_SECRET) - verify_receipt(apple_sub.receipt_data, user, MACAPP_APPLE_API_SECRET) + if "io.simplelogin.macapp.subscription" in apple_sub.product_id: + verify_receipt(apple_sub.receipt_data, user, MACAPP_APPLE_API_SECRET) + else: + verify_receipt(apple_sub.receipt_data, user, APPLE_API_SECRET) LOG.d("Finish poll_apple_subscription")