0

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 (i.e. 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?

Martin Mlostek
  • 2,755
  • 1
  • 28
  • 57

1 Answers1

0

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

Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
  • well, but what about a re-installment? everything is working fine, i am just wondering how to distinguish a new purchase from a restore-purchase transation – Martin Mlostek Feb 11 '18 at 20:39
  • If you have a login system make a boolean upthere in server if not , users already know that and Apple will reject your buy VC if it hasn't a restore button – Shehata Gamal Feb 11 '18 at 20:41
  • there is no user management or other server involved, so i cannot persist this information anywhere – Martin Mlostek Feb 11 '18 at 20:42
  • actually re-charge won't happen again anyway even if user clicks buy button delegate will run only , as Apple servers already keeps these data – Shehata Gamal Feb 11 '18 at 20:45
  • i know. maybe i was not clear. everything works fine. the only thing i want to find out, is "did the transaction with the state '.purchased' charge the user or not" – Martin Mlostek Feb 11 '18 at 20:46
  • You mean if user buy the IAP then deletes it and reinstalls it a gain and click bug , answer is re-charge won't happen again , to be sure try a payment of your own app from an account and do it again charge is only once for a Consumable IAP – Shehata Gamal Feb 11 '18 at 20:50
  • yes.. thats the scenario what i mean. the user is not charged, but the transaction within `paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])` will have the state `.purchased` and not `.restored` – Martin Mlostek Feb 11 '18 at 20:51