Apple in app fix (#1369)

* error log if issue with apple sub

* use the right secret when polling apple sub
This commit is contained in:
Son Nguyen Kim 2022-10-25 19:45:53 +02:00 committed by GitHub
parent 87047b3250
commit 2f769b38ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -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

10
cron.py
View file

@ -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")