I am implementing In App Purchases in my app and I am using Non-Consumable Products. I have User Login in my application and to prevent Irregular Activity apple sugests to use applicationUsername property, so I can send along with the payment the user's username.
Everything works fine, i can set payment.applicationUsername property and I can retrieve it back after the purchase is finished in SKPaymentTransactionStatePurchased state.
The problem is that, when i try to Restore my transactions with the restoreCompletedTransactionsWithApplicationUsername: method the applicationUsername property returns NULL.
Can you help me please?
After a lot of research i found that we can't use applicationUsername for this purpose.
For a restoreCompletedTransaction you can use the transaction.originalTransaction.transactionIdentifier property (and it's equivalent under a new purchase - transaction.transactionIdentifier).
That is a unique identifier associated with the Purchase itself and iTunes Account that is found in the restore record.
1. How to use it:
Record that Original transactionIdentifier on your server as associated with the original purchase by user A.
2. Detect Irregular Activity
If another user tries to restore their purchase check to be sure the transactionIdentifier has not already been used under a different userName.
If this transactionIdentifier has not been been used from none of your users than make your restore successful. If the transactionIdentifier has already been used from another user than explain the user why you can't make the restore.
This is essentially equivalent to using 'transaction.transactionIdentifier' as the 'applicationUsername'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With