in app purchase - local receipt kept being found

Hi all, I hope someone can help me understand:

I am doing local receipt validation in my new app and it works fine, using a sandbox test account, XCode installation and buying the in-app purchase.

Then I tried to test more code with a new sandbox test user: delete my app, sign out of AppStore, start app and as expected: no local receipt found. Upon second run-start - on same device - without having refreshed receipt or signed in, somehow a receipt is found and validated.

To test a new purchase or restore procedure with a new user, I have to ignore the code recognizing a receipt in code.

Is that normal? I am pretty sure that did not happen last time I used local receipt validation.


By the way, I tested sandbox users with a fake email (also used for first time purchase) and sandbox users with a verified email but a receipt is always found.


Thanks for your help!

Replies

A new receipt will appear when StoreKit calls updatedTransactions. Otherwise there may or may not be a refreshed receipt attached to the binary.


You worte:

> To test a new purchase or restore procedure with a new user, I have to ignore the code recognizing a receipt in code.


Huh? Here's what you do - You check to see if there is a receipt. If there is no receipt you inform the user that they need to refresh the receipt and you refresh the receipt. If there is a prexisting receipt and that receipt does not provide the requested content to the user then you indicate to the user they might want to refresh the receipt.

Post not yet marked as solved Up vote reply of PBK Down vote reply of PBK

Hi PBK, thanks for your answer already. It helps but I think I was not clear enough.

First, I am in the XCode/Sandbox testing phase (I will later move to Testflight/Sandbox prior submission).

I use local receipt validation and have successfully used the coding just one year ago.

I wanted to test: purchase with user 1 (worked) - then restore with user 2. I was expecting that to fail as user 2 has not bought anything yet. And here is the problem:

  • I sign out
  • delete the app - so was expecting that no receipt is available
  • install app through XCode fresh and start app
  • Upon start, there is a search for a stored receipt in the code. When it is first started, the app correctly says - no receipt
  • I stop the app and start again through XCode. And all of a sudden it not only finds a receipt, it finds one with purchased information, i.e. releases all requested content


In order to still test RESTORE functionality with user 2 (and indeed user 1), the only way at the moment for me to test that in development (of course I would not do that in production) is to just accept that there is a receipt but still ask for RESTORE.


You wrote: Otherwise there may or may not be a refreshed receipt attached to the binary.


Could it be that XCode/StoreKit realises the device has "bought" once in Sandbox the app and therefore - unasked - installs a valid receipt?


UPDATE:

Interesting - I updated the software on the device to iOS 10.3.2 and now everything is as it should be. I delete the app, repeatedly start it through Xcode and now, repeatedly no valid receipt is found 🙂 without purchase.

I am running in to the exactly same issue you're describing! in fact, I would have written the problem in exactly the same way...
Did you find a solution for it? Or may what I am (you were) doing wrong?

Hi Tarek,

yes, as you can see in my update, once I updated my iPhone to the latest software (at that time), the behaviour went back to expected behaviour - without me changing the programme code in any way. So I assume that it was due to my device and not the programme, e.g. a hanging transaction observer. Maybe try another device to see, whether behaviour is correct? Good 'luck'!