iOS app - Logic to implement for in-app purchases - ios

We have a non consumable IAP in our app which costs €3.49. I have purchased the IAP on my phone ages ago and also tested restore a couple of times and everything works just fine. This morning however, while testing the app, I uninstalled and installed the app from the App Store back on my phone. Instead of tapping 'Restore Purchases', I chose to 'Remove Ads', hence purchase the IAP again. I thought that the SDK(Xamarin.InAppPurchase) itself, would automatically track that I had previously purchased this IAP and it would go through the restore process on its own. However, I was proved wrong since a couple of minutes later, I received an invoice from Apple, that I had purchased the IAP again. I also received a statement from my bank for my purchase.
So my question here is: shouldn't the SDK itself check that the IAP was previously purchased under the Apple ID I was using? Should I amend my code on 'Remove Ads' to firstly go through the restore process and if I get a fail callback then move on to the actual purchase process?

Server side should check if non consumable purchase was made before or not.
In case if you try to buy second time your should get message like this:
"You have already purchased this. Do you want to
purchase this again for free?"
It works for non consumable purchases. Check inside itunesconnect if your app really non consumable, probably you made it consumable by mistake.
Also FYI info from apple communities:
https://discussions.apple.com/thread/5574903

Related

iOS - Identifying and activating purchases made from the App Store

IAP (Subscriptions) can be purchased from the App Store through IAP Promotions or Offer Codes. In the case where the app is not installed yet, I was wondering how to activate the purchase afterwards.
If the subscription was activated through the App Store or an Offer Code was redeemed in the App Store, is it added to the receipt automatically? I guess so, otherwise I would have to restore the purchase, which I think is wrong.
Since I can not test this use cases from a sandbox account, would be very nice to know about the behaviour in advance. Thanks!

In-App-Purchase subscribed state in Swift?

So I have a question about doing an in-app purchase with a subscription in swift. I read at this link: https://www.revenuecat.com/blog/the-ultimate-guide-to-subscription-testing-on-ios#sandbox that you need your app to enter subscribed state. Is this some kind of delegate method or something I call, or does it simply mean that I enable the features? I haven't been able to find much detail on that part. Any guidance would be much appreciated. I do have the in-app purchase dialog appearing and the sandbox account working. I also get the alert saying the purchase was a successful. But even 2 seconds later if I try again it just allows me to purchase again.
By subscribed state they mean that a user still should have access to the content he unlocked with the subscription.
But even 2 seconds later if I try again it just allows me to purchase again.
Unfortunately, it is your responsibility to hide already bought in-app purchases from your users. Although, Apple prevents buying the same subscription again. So, when your first purchases succeeded, the second one should lead to an alert from Apple, that the purchases weren't executed. Otherwise, I assume your purchase logic is faulty.
How do you check the eligibility of your users? Do you validate the receipt locally, or are you using RevenueCat for that?

When are In-App Purchases activated after app has been approved for sale

I just made my first IOS app which has an IAP option and today it has been approved by iTunes Store. After I got the email, I had to wait another 4 hours before the app actually has been added to the App Store.
After I search for it and download it on my phone I decided to test the IAP option, but it doesn't seem to work. I am using my original Apple ID email and not the one I used for testing.
My question is, if the app has been added to the store, does the IAP has to work ? Or you have to wait awhile ? Just like waiting for the app to be added to the store after it has been approved.
PS: both the app and IAP has been approved by Apple and the status of my app is Ready For Sale.
edit:
If I run my app now from Xcode I get the following output from my code:
About to fetch product
Fetching products
Got response from Apple
Black Edition Theme
Black theme
0.99
Sending the payment request to Apple
Received payment transaction from Apple
Received payment transaction from Apple
Restored
Received payment transaction from Apple
It works how it should, but it keeps asking me for my Apple ID password continually and at some point said Cannot connect to App Store even if everything was successful, and after I click Retry I get the Confirm Your In-App Purchase screen but it also says Environment: Sandbox
I'm really confused why the sandbox screen is appearing.
Apple's servers often lag behind directly after updating an app with a new IAP (the product will not be found by the API). Waiting a few hours usually resolves the problem. We've had this with every new IAP we added.
You say the IAP "doesn't seem to work" ... what do you mean by that? You are charged for it, but you don't get the new content / feature / whatever it is? Or you select Purchase in your app but nothing happens?
It's been a while since I worked with IAP, but back when I did you had to submit at least one IAP component at the time you submitted your app for review. So both were reviewed at the same time.
If that's what you did, the IAP should be available immediately - if it's not, yeah... something's wrong.

How to detect if user has made any in-app purchases?

My iOS app has in-app purchases (consumable) and shows ads periodically. The idea is to remove ads after user has purchased anything. But in-app items are consumable, so after user re-installs the app, I would be unable to determine if he has purchased anything using [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];, right? And I would bomb him with ads again...
What would you suggest to find out that the user has purchased anything already?
Well when a user re-installs your app (i.e. delete it and install it again) there is no immediate way of knowing what purchases did he made. That's why Apple requires your app to provide a way to restore previous purchases so that when the user performs this operation he restores these purchases for free.
For consumable items you might need to use a server for managing the purchases such that when the app loads it checks with the server which purchases the user has made and immediately enable the relevant content.
I do not know if mandatory but "Remove Ads" IAP should be non-consumable so the user will only need to purchase it once (Otherwise I believe users will complain or just won't buy it).
Some creative ways can be found here : iPhone - in-App purchase consumable correct approach
As an improvement on the situation, you could store the fact that a purchase was made in NSUserDefaults. That won't survive if the user uninstalls and reinstalls the app, but at least it survives if the user buys a new phone and restores a backup to transfer everything to the new phone.
You could have a look at Cloud Kit as well, which would store information per AppleId. It's a bit overkill for the problem, but it means you can use Apple's servers instead of your own for free. There would be a difference that if a user installs your app on six devices, makes a consumable purchase on one device, ads will stop on all of them.

In-App Purchases restore button necessary?

guys I've implemented an in-app purchase using PARSE. Now there is no restore button in my app . My DB, hosted on the PARSE cloud has a an attribute called "hasMadePurchase" in my User's table which is checked every time the user tries to make a purchase. The attribute is set to yes as soon as a successful purchase has been made.
Now with that, do I need a restore purchases button for the app to get it through the app store? Cause clearly, even if the user changes his/her device deletes and re-installs the app or whatever he/she will still be able to get all his/her purchases back.
If yes, than what do I need to implement in my restore function? (which would basically do nothing, other than making fake calls, i don't know i am kinda lost)
A restore purchases button is needed only if the app offers non-consumable IAPs, e.g. unlocking content. Our game got rejected recently exactly for this reason - we were offering weapon unlocks and we were missing the restore purchases button.
If you are offering non-consumable IAPs then you can start by looking into [[SKPaymentQueue defaultQueue] restoreCompletedTransactions] and go from there. Basically, this fetches the list of all IAP SKUs that have been previously purchased by the user.

Resources