Skmutablepayment Property: Applicationusername

SKMutablePayment property: applicationUsername

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'.

Is there any way to know purchase made by which iTunes account? - iOS

As of iOS 7, SKMutablePayment has an applicationUsername property that can be set when a payment is made. And, SKPaymentQueue has the restoreCompletedTransactionsWithApplicationUsername: method (link).

Apple's guidance is to hash your server-side user ID and pass that up on purchase and restore. So, in your case, if iTunes User A purchases the product it will be bound to your server-side user ID for that purchaser. Then, if iTunes User B attempts to restore, restoration will fail, because they would still be passing up the same server-side user ID.

You'll also have to track (on the server) that your server-side user ID has purchased the product. Otherwise, if iTunes User B attempts to restore you'll need to know the difference between they having logged into the device with a different iTunes account and they having never purchased. And of course, you'll also want to prevent the same server-side user from purchasing the product twice, under different iTunes accounts.

Caveats:

  • If you already have purchases made in production, this most likely won't work.
  • iOS 7+
  • The "already purchased" scenario I mentioned above.


Related Topics



Leave a reply



Submit