Purchases not always works

Hi,


I have developped an app with the Iocin framework. Used a 3th party plugin for the in-app purchases from GitHub (cc.fovea.cordova.purchase).


The purchases is for the full version of the app and no ad display. In the test phase all is good. In the live version in the App Store, all goes fine except in some cases the purchase is done but the app does not unlock the full-version. Its a smartphone only app (iOS and Android).


Some examples for better understanding in the live version:


With appleID-A i am on a iPad and buy the in-app purchase 'full-version'. Done, the app unlocks the full version as expected. With the same appleID-A I am also on an iPhone. I press the restore purchases but does not work, The app does not unlock the full-version but the state is owned. If I reinstall the app on the iPad and press restore purchases it is unlocked, just a test if it works


Now I use AppleID-B (already own the full verion) on the same iPad, restore, all goes as planned, full version unlocked. Now I log in on that iPhone with AppleID-B, install the app again, press the restore button and the app unlocked the full version, as expected.


If I login with AppleID-A on a different iPhone, press restore purchases, the app unlocks the full version.


So as you can understand I spent two weeks looking through my code but cant find anything... it looks to me that with a specific AppleID and a specific device it will not work, but WHY? 😕


Anybody seen this before and can explain why this is happening in some rare cases?


Kind regards,

Roger

Roger,


It's difficult to debug an issue given only a user level description of the problem. However, I can make some guesses. You indicated that


"With appleID-A i am on a iPad and buy the in-app purchase 'full-version'. Done, the app unlocks the full version as expected. With the same appleID-A I am also on an iPhone. I press the restore purchases but does not work"


The likely reason why this happens is that the finishTransaction call was not made to complete the transaction in the iPad purchase. If the finishTransaction call is not made, the transaction remains incomplete and will not be "restored" when the restoreCompletedTransaction call is made. Another question - on the iPhone, was appleID-A defined as the iTunes/App Store user setting when the restoreCompletedTransaction call was made, or did you enter the id. My reason for asking is that if the addTransactionObserver call was initiated, it should have found the incompleteTransaction and processed it. The observer can only process an incompleteTransaction if it has a user specified already.


You then state - "If I login with AppleID-A on a different iPhone, press restore purchases, the app unlocks the full version." In this case I wonder if the user was now defined so that the transactionObserver completed the transaction, not the restore process. Having programmatic details would help to understand what is happening.


One other thought, if you are using a framework, you need to ensure that the addTransactionObserver call gets made preferably in the didFinishLaunchingWithOptions delegate method. It's my experience that not doing this has resulted in most of the unusal StoreKit problems which I handle here in DTS. This is also a Best Practice as per Tech Note 2387 iAP Best Practices

<https://developer.apple.com/library/content/technotes/tn2387/_index.html#//apple_ref/doc/uid/DTS40014795>

Actually, the transactionObserver can be installed at a later time, but it needs to be installed prior to when the user might expect to make use of premium content that is available through an in app purchase.


I could well be wrong on my analysis above - having programmatic details as to what is happening helps - if the app logs different stages of StoreKit API use, I'd capture the console log when the problem occurs. Barring that, one can still obtain a lot of diagnostic info by installing the App Store/iTunes Store profile available from the Apple Developer Bug Report web page <https://developer.apple.com/bug-reporting/profiles-and-logs/> then capturing the console log.


rich kubota - rkubota@apple.com

developer technical support CoreOS/Hardware/MFI

You wrote the following:


>With appleID-A i am on a iPad and buy the in-app purchase 'full-version'.......With the same appleID-A I am also on an iPhone. I press the restore purchases but does not work....If I login with AppleID-A on a different iPhone, press restore purchases, the app unlocks the full version.

So - will that first iPhone's 'restore' function work if you shut the app off and turn it back on again? If not - what else is different between those 2 iPhones?

Thanks for the answer, I will clarify some things, this is my very first app so just a beginner. Made the app in Visual Studio with the Cordova Tools extension. Build the app in Adobe Phonegap online tool. Its an hybrid free app with in-app purchases.


What I did to test is delete the app from iPad-A, iPad-B, iPhone-A and iPhone-B, logout on all devices in iTunes.


1) iPad-A: I login in iTunes with AppleID-A, go to the app store, install the app and restore the purchase, full version unlocks.

2) iPhone-A: I login in iTunes with AppleID-A, go to the app store, install the app and restore the purchase, full version does not unlock

3) iPad-B: I login in iTunes with AppleID-A, go to the app store, install the app and restore the purchase, full version unlocks.

4) iPphone-B: I login in iTunes with AppleID-A, go to the app store, install the app and restore the purchase, full version unlocks.


Delete the app on all devices and log out and do the same tests on all devices with AppleID-B, all 4 tests pass and unlocks.


Can I post the code here, or if you want to takea look is it better to send a PM?

One is a iPhone 5 running iOS 9,x, other is an iPhone 6s with iOS 10.x.


Did 3 tests now and all 3 Apple ID's own the in-app purchase in the live situation. But only Apple ID does not restore correct on the iPhone 6s. The others work as planned. Delete app, logout, login, install the app, restore procedure. in 99,9% it works as intended. But receiving emails from members it does not work. They pay but nothing unlocks, thats not good. I have ffered them some other free things so they are happy for now till I fix the problem. But I cant ignore this offcourse.

And on the iPhone 6s....if you delete the app, reinstall under a specific Apple ID, purchase the IAP under that Apple ID, delete the app, resinstall without changing Apple ID and then restore - does it restore? Perhaps the Apple ID on the 6S is different from the Apple ID used to purchase the IAP on the other devices.

Nope, no luck.

The IAP is owned, get the message to get it for free again... but nothing happens (same with restore).


If i delete the app, and download it with my own Apple ID where I also own the IAP, it works as it should be on the 6s. But not with the other Apple ID.


I even did a test in the sandbox, all works good. Did uploaded the app to the testflight and gave the Apple ID where it was not working with access to test it in testflight. It works as it should be. Nothing changes and uploaded the app to the app store. The specific IAP is not working with that Apple ID.


Think it is time to look at another cordova IAP plugin.

Here is what I wrote:

And on the iPhone 6s....if you delete the app, reinstall under a specific Apple ID, purchase the IAP under that Apple ID, delete the app, resinstall without changing Apple ID and then restore - does it restore? Perhaps the Apple ID on the 6S is different from the Apple ID used to purchase the IAP on the other devices.


Here is what you wrote:

The IAP is owned, get the message to get it for free again... but nothing happens (same with restore).

If i delete the app, and download it with my own Apple ID where I also own the IAP, it works as it should be on the 6s. But not with the other Apple ID.

So the procedure you described above for "with my own Apple ID" works as expected. Good. But did you do the same procedure with the other Apple ID - did you delete the app and download the app using that Apple ID???? Or are you trying to purchase an IAP with an Apple ID that differs from the Apple ID used to install the App?

Also - is the App Store telling you you can get it for free and then your code is not responding correctly?

I try what you said and it was no luck, did not work (Nope, no luck.)


The procedure for all the different Apple ID's is the same:

- delete the app

- log out

- log in with Apple ID

- download the app

- buy IAP


With that said, the app works as expected with 3 different Apple ID's, except for one. In the TestFlight the app works with the Apple ID where it fails in the live enviroment, with exact the same app code.

The app store is telling me I already own the IAP (non consumable) and then I can get it for free again. Works on 3 different Apple ID's on the same iPhone 6s, except the one. They all own it for sure, as I have seen the payment details myself.

On an iPad the IAP works with the Apple ID where it fails on the iPhone.


Its such a weird thing that it works in 99% of the cases, that I decided to try another IAP plugin from github. The cc.fovea.cordova.purchase has to many issues... Saw an issue from somebody with the same problem more then a year ago... the developer didnt answer that question.


Switching to cordova-plugin-inapppurchase, hope that one works better.


Thanks for your help!

So the specific thing about the Apple Id that doesn't work is that it was used to purchase the IAP in the Testflight version - is that correct? Wasn't that 'purchase' done in the sandbox environment for free and not the production environment?

>>o the specific thing about the Apple Id that doesn't work is that it was used to purchase the IAP in the Testflight version - is that correct?

The IAP was already owned before the TestFlight. Used the testflight for the new app version for better user feedback as with some people it does not work.

I got now like 10 people from the 1000 where it does not unlock the IAP. Thats 10 to much 🙂


>>Wasn't that 'purchase' done in the sandbox environment for free and not the production environment?

No the purchase was done as the app went live.

Are all of your 'failures' comming from users who

used their Apple Id to restore or purchase the IAP

on your app on at least one occasion

when your app was in TestFlight?


If so, it is not unreasonable to suspect that the App Store has mistakenly assigned that purchase to the sandbox environment and your problem is specific to TestFlight use of Apple Ids.

No, cause I only used the TestFlight for the lastbuild. Never used it before. All is happening before that. And if that where the case, it wont restore on the iPad with that same Apple ID thats fails on the iPhone.

Purchases not always works
 
 
Q