Back to blog

The Ultimate Guide to In-App Purchase in iOS Application Development: Part 1

error pic
clock

7 min read

What does in app purchases mean? Mobile app development for businesses usually aims to create one more channel to serve clients and sell products and services, both physical and digital. To put it short, businesses earn money via mobile apps. Though monetization models may differ, when companies want to sell content within their apps, they will face the need to implement in-app purchases that renew automatically.

In app purchases are now a typical feature of practically all apps. Our company specializes in mobile app development, and our team of highly competent programmers has incorporated payment systems into a variety of digital services that offer in app purchases.

You’ll learn about the challenges we faced and why we opted to tackle them by developing our own solution for app purchases on iOS. We’ll also talk about switching from an external to an internal payment processor.

Real-world examples from two of our most successful iOS business apps for customers will demonstrate how to create a custom dependency to handle financial transactions. Finally, we’ll discuss why it’s beneficial to create an iOS in app purchase library from the ground up for a commercial project.

In-app purchases overview, terms, and definitions

An inapp purchase (IAP) for app users is any fee (in addition to the initial cost of downloading the app) that the software may request.

The IAP functionality can provide users with additional features, content, or digital products, while in other cases, it serves as a subscription that requires users to pay to use the application. Subscription often goes after the free trial.

Creating an Apple ID on the App Store requires adding a credit or debit card to cover all the costs associated with downloading paid iOS applications.

What does in-app purchases mean? Since applications are downloaded from the store, they can directly withdraw funds from the card associated with the account, making purchases within the iOS application very susceptible to hacker attacks, since there is no need to enter credit card information again or enter a password to book a transaction.

Types of iOS in-app purchases

As Apple states, there are four types of in-app purchases, that an iOS, macOS, or tvOS application can provide different types of in app purchases:

  • Consumable. This type of products and digital content can be purchased as many times as a user wants it.
  • Non-Consumable. This type comprises non-consumable, premium app functionality. Those features implement in app purchases once and do not expire. Some content associated with a non-consumable purchase can be stored on Apple’s side.
  • Auto Renewable Subscriptions. In this case, users are charged periodically for access to premium content. It is a recurring purchase and app subscriptions can be canceled anytime in the App Store settings.
  • Non Renewable Subscriptions. This type is the ability to purchase access to some goods or content in an iOS app for a limited period of time. This subscription form is not repetitive, so app users need to buy a new member each time they need it.

In WatchOS, in app purchase is not supported. But who knows what Apple will do next?

The Overview of the iOS in-app purchase lifecycle

In general, all iOS IAPs are realized the same way.

  1. A software solution requests all available products from a server-side and shows them to users;
  2. A user selects a product to purchase through UI;
  3. A system adds the purchase request to the App Store purchase queue;
  4. When a consumable in app purchase is successfully processed, the application is notified;
  5. A purchase receipt is sent for validation to the app’s server-side;
  6. As soon as the validity check is passed, user gets access to the requested products or content.

So, this is how a purchase circle looks in general, and it works perfectly in theory, but there are a lot of traps and pitfalls in practice.

In real life in app purchase iOS flow is much more complicated than the infographics above. So what actually happen when a user taps a “Purchase Now” button in an iOS app? Let’s dive into Apple’s StoreKit.

  1. A user taps a purchase button on a screen of an iOS app.
  2. For every iOS application that makes purchase requests, StoreKit creates a SKPaymentQueue. Every queue has a listener that can respond to any modifications of the request queue. In other words, when the system sends an iOS in app purchase request, it is added to quite a long cue. There can be several purchases at once, and all of them will be processed sequentially, one by one.
  3. After adding a purchase request to the queue, it is validated to determine whether a user is allowed to make it. Then a series of checks is performed, such as if a user has Apple ID account, if a payment card is added, if there is no information available for in-app purchases, and many other criteria. The results of these validations are sent to the queue.
  4. In practice, a user can see a dialog requesting to enter a username and password from his account before buying digital goods, as in the above-mentioned example. As soon as a purchase is settled and it has passed the validation successfully, a notification will be added to the queue awaiting processing again and initiate data re-processing. However, there can be several purchases, as well as validation checks, in that queue.
  5. When the request is processed successfully, a local product receipt gets updated with purchase details. Then we should mark the transaction as finished.
  6. After those steps, user gets access to premium features or content in the iOS application on their Apple devices.

All these factors, like asynchronous nature of requests and poor architecture, can lead to asynchronous purchases in business iOS applications, thus leading to negative user experience and customer attrition. So, choosing approaches to app purchase capability in iOS, developers and stakeholders should keep in mind a bundle of asynchronous requests and responses, along with possible architecture-associated issues.

An app owner should also know how to change in app purchase account Apple and some other questions. However, you may leave this to your developing team, too.

Business tasks and challenges of purchases in iOS apps

The first business case: an iOS app selling consumable products

One of our client’s business app provides its customers with a service of communication with psychic advisors and mediums to find answers and clarity in their lives. The app uses a freemium monetization model — some functionality is free for registered users, while for live communication (one of the premium features) a fee is charged. One of the payable features is a chat with an advisor. To offer this functionality to its users, the iOS app is using in-app purchases. Before the chat starts, an app user adds funds to their balance, and these funds can be charged for a chat with any available advisor. Users also know how to change in app purchases.

If we turn business tasks of the mentioned app into the main requirements of IAP (in-app purchases) development, they would be the following:

  • Fetch the list of products, i.e. “Minutes bundles”, as the main action required for adding funds to a user account;
  • Check if a user’s Apple ID is allowed to make purchases and whether this ID has an App Store connect to the region where the paid content is provided by the app;
  • Provide a consistent purchase flow, prone to network errors and disconnects.

The second case: an iOS business app offering services subscription

Another business case, we would like to mention as the example, offers users various astrological services. In-app purchases are implemented to provide a subscription feature. The app user can subscribe to a premium service and get more content compared to a standard offering. All premium content from the app is accessible across multiple devices by using in-app purchases Apple ID.

In this article we could also make an auto-renewable subscription iOS tutorial but it was not necessary.

When starting an application, the system checks if a user’s subscription is still valid defines which content to show, and makes corresponding changes to the UI.

So, in this case the main development requirements for consumable purchases are:

  • Determine what types of subscriptions are available for iOS in app purchases for every app user;
  • Confirm the ability of the user’s Apple ID to make purchases and provide testing in app purchases;
  • Provide an in app purchases mean;
  • Validate current subscription state (a type of subscription, trial period, etc.).

Conclusion

So what does it mean in app purchase? In-app purchases in iOS application development are a challenging feature that requires hands-on experience, a comprehensive approach, and a lot of hours to implement. Nevertheless, this functionality often serves as the main source of revenue for software products and games. All you user needs is a credit card.

Creating a custom in-app purchase library and allowing its free usage, our goal was to facilitate embedding in-app purchase functions for our clients and partners, thus shortening their time-to-market and cutting the development cost. This is how app purchases work.

Dashdevs created its own guide to in app purchases that covers requirements and solves the most common pains, like asynchronous execution, availability of separate instances, local receipt validation, and more. The purchase library is available at GitHub under MIT license. Use it, enjoy, and tell us whether our custom in-app purchase library was helpful for your iOS development challenges in the feedback and comments section below the article.

FAQ

What is the difference between in-app purchase and subscription?

Apps may charge users for “in-app purchases”, or the money required to acquire digital content inside the app itself after the user has already downloaded and installed the program. To use the entire range of features accessible in the app, members must pay a recurring subscription (either weekly, monthly, or yearly).

Does Apple take 30% for all in-app purchases?

Apple’s new App Store policy allows for the legal purchase of non-fungible tokens (NFTs) in-app on its platform, but it also imposes a 30% transaction fee, which has been seen as a de facto limitation on their sale.

Which framework is needed to support in-app purchases on iOS?

You may incorporate a purchasing experience straight into your app with In-App Purchase using the Store Kit framework. Before seeking the user’s permission to continue with the transaction, the framework creates a secure connection to the App Store on your app’s behalf to manage user payments.

Share article

Table of contents