Handle the case "Restore Purchase" on another account

This commit is contained in:
Son NK 2020-04-19 23:13:43 +02:00
parent b5b4fe2773
commit 840f827b45
1 changed files with 6 additions and 1 deletions

View File

@ -269,7 +269,7 @@ def verify_receipt(receipt_data, user) -> Optional[AppleSubscription]:
if apple_sub:
LOG.d(
"Create new AppleSubscription for user %s, expired at %s, plan %s",
"Update AppleSubscription for user %s, expired at %s, plan %s",
user,
expires_date,
plan,
@ -279,6 +279,11 @@ def verify_receipt(receipt_data, user) -> Optional[AppleSubscription]:
apple_sub.original_transaction_id = original_transaction_id
apple_sub.plan = plan
else:
# the same original_transaction_id has been used on another account
if AppleSubscription.get_by(original_transaction_id=original_transaction_id):
LOG.error("Same Apple Sub has been used before, current user %s", user)
return None
LOG.d(
"Create new AppleSubscription for user %s, expired at %s, plan %s",
user,