Introduction:- In Apple development In-app purchase is a great way to earn money from your iPhone, iPad, iPod touch, or Mac app. We can detect if some app offers an In-app purchase by going to the app page, and seeing if it has “Offers IAP” or “IAP” near the Price, Buy, or Get button. In-app purchases are mostly used to unlock some extra content in our app that we want to monetize from. Like it or not, Apple charges 30% of each successful transaction that your app will make payment.
Motivation:- A normal version of our app with additional paid and premium features.
A game that offers new environments (levels) to explore.
An online game allows players to purchase the virtual property (money).
But there are some more reasons for developers to implement IAP:-
Money:- We can earn more money than just one time the price of our app! Some users are willing to spend a lot of extra content (freemium strategy).
Market Share / New Business Models: We can release our app for free, which is a no-brainer download for most people → more downloads/users reached. If users enjoy our app, they can purchase more in-app functionality.
Easy Maintenance: We can keep adding additional content in the future for the same app, rather than having to make a new app to earn money with IAP.
Types of In-App Purchase
1 – Consumable:- The user needs to buy any items every time he wants them. Examples of consumable purchases are buying game coins etc.
2 – Non-Consumable:- If the user buys an item, he will have it forever. This is a one-time purchase, and users can also transfer it between devices connected with the same Apple ID. For Example: upgrading an app with the latest version.
3 – non-renewing subscriptions:- Using the app content for a fixed period of time, and the user can buy it again. For example, an education season.
4 – Auto-renewing subscriptions:- We can subscribe to the content or the services that the app is offering for a specific period of time. It will automatically renew when the period has passed away. For Example, player subscriptions, Netflix, games, etc.
Connection Project and App Store:-
Product Configuration On iTunes :-
On the next screen, you can set up all the info about your product on iTunes:
Reference Name: This name will be used on iTunes and in Sales and Trends reports. It won’t be displayed on the App Store and you can type any name that you want, but it can’t be longer than 64 characters.
Product ID: A unique identifier that will be get by the app in order to recognize our product. Usually, developers use a web-reverse syntax for productID. In this example we chose com. Demo. coins. After on we’ll paste this id as a string into our code to get product info.
Price: Choose a price from the dropdown menu on the product info page. Remember that in order to sell our in-app purchase product on the App Store, you must have applied for a Paid application agreement, Tax & Banking section.
Localizations: We’ve chosen only English, but you can add more languages by clicking on the plus button on the product info page. Then type a display name of a product and a description. Both of them will be visible on the App Store.
Screenshot: Upload a screenshot for review by apple. It will not be displayed in the App Store and it must have a valid size given for your app platform, if your app is Universal, you may upload an iPad screenshot.
Review Notes: Any additional information about your IAP which may be helpful for the reviewer.
Product Configuration Price & Duration:-
Store Kit Configuration
- Enable In-App Purchase in our project from the capabilities section.
- Add Store kit framework in our project.
About Store Kit:-
We will handle how to get product information into our app with product id.
– Process of purchasing with store kit
– We‘re gonna a short look into restoring completed transactions and heading
– Very short: How to get receipts.
Flow Chart Payment Process:-
Store Kit Classes:-
Implementing IAP requires the following classes of StoreKit framework:-
SKProductsRequest – A request to StoreKit for approved products to sell (App Store). Can be configured with a number of products with the array.
SKProductsRequestDelegate – Declares delegate methods to handle product requests and responses with product info.
SKProductsResponse – Sent back to the delegate from StoreKit (App Store). Contains the SKProducts object containing all the product info, that matches the product Ids sent with the request.
SKProduct – A product retrieved from StoreKit with delegate method (that you are configured in iTunes Connect). Its Contains all information about the product, such as Product ID, Title, Description, Name, and Price.
SKPayment – Created with a Product ID and added to the payment queue to perform a purchase and handling transaction.
SKPaymentQueue – A queued payment request to be sent to Apple. Notifications are triggered as a result of each payment being processed.
SKPaymentTransaction – Represents a completed transaction (a purchase request that has been processed by the App Store and sent back to your application via StoreKit) delegate. The transaction could be Purchased or Restored.
SKPaymentTransactionObserver – Custom subclass that responds to events generated by the StoreKit payment queue and manage the payment queue.
StoreKit operations – After a SKProductRequest is started or a SKPayment is added to the queue, our SKProductsRequestDelegate or SKPaymentTransactionObserver subclass when receives a receipt from Apple’s servers.
By – Pradeep Singh