How to code and test StoreKit pending purchases in Swift and XCode

Oscar de la Hera Gomez
Three flowers that represent StoreKit, Swift and XCode side by side. Beneath them sits the text “Code & Test StoreKit Product Pending Purchases.”

A step by step guide on implementing and testing StoreKit product pending purchases for In-App Purchases and Subscriptions.

The guide was made using our Free iOS StoreKit 2 Open Source project which is recommended for developers or business folk wishing to learn about how In-App Purchases or Subscriptions work and the code behind them.

The following walkthrough assumes that you have already setup StoreKit with an offering and developed a UI that allows an app to display products.

Please consult the guides below to learn how to setup StoreKit, create a StoreKit offering or design a UI that considers all StoreKit scenarios.

Step One: Setup StoreKit Purchases

A screenshot of an iOS app showing a completed purchase.

Follow our guide below to setup StoreKit purchases.

Step Two: Enable Ask to Buy

A screenshot of Xcode highlighting the location of the Editor tab in the Xcode menu and Enable Ask to Buy. If Ask to Buy is already enabled, this will say Disable Ask to Buy.

Follow our guide below to enable Ask to Buy in XCode.

Step Three: Make the purchase

A screenshot of an iOS app asking for permission after requesting a purchase of a non-consumable in-app purchase.

Run the app and attempt to make a purchase.

The app will prompt you to ask for permission.

You should also consider marking the transaction as pending using UI similar to the one below.

A screenshot of an iOS app showing a non-consumable in-app purchase in a pending state.

Step Four: Approve or Deny

A screenshot of the XCode StoreKit Transaction Manager. Highlighted is a pending transaction. We have used arrows to point out the tick and cross that appear after selected a pending transaction. The tick approves the transaction whilst the x denies it.

Follow our guide below to learn how to approve or deny a pending transaction.

If you deny a pending purchase, your app will not be notified via the StoreKit listener. This means that in order to update from the pending UI, your app must request the product purchase state again for it to know the transaction is not pending. We recommend requesting product statuses every time an app enters the foreground.

If you approved the purchase, your app will be notified via the StoreKit listener and you should use this to update the UI to show that it has been successfully purchased.

A screenshot of an iOS app showing a non-consumable in-app purchase in a purchased state.

Looking to learn more about developing apps with StoreKit 2?

Read our comprehensive development guide linked below to learn about all the secrets behind developing In-App Purchases and Subscriptions with StoreKit 2.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details