简体   繁体   中英

iOS IAP: How to veriy that user was really charged for transaction

I am using

paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])

and inside I am of course handling the transactionState . Everything is working fine, but now I want to add proper tracking.

There is the special case, when a user bought the SKPRoduct already before but hits the buy again (ie after a fresh install) Then he wont be charged again, but the transaction state will be .purchased even though it was a restore.

Is this only happening in the sandbox environment? I did not yet publish it so I don't have any live experience about this, but I wonder if there is a correct way to find out if the transaction was really a purchase, or in fact a restore?

First of all when user installs the app and clicks buy you dim the display and wait until delegate methods inform you that payment occurred successfully then you store a boolean in user defaults that user bought the IAP , whenever you open the VC with buy button check the boolean and hide/show it accordingly

Note: re-charge won't happen again if user deletes the app after purchase and installs it again and clicks buy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM