How to test failed 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 “Test StoreKit Failed Purchases.”

A two step guide on testing failed StoreKit product 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 and buy them.

Please consult the guides below to learn how to setup StoreKit, create a StoreKit offering, setup your app to be able to purchase StoreKit products or design a UI that considers all StoreKit scenarios.

Step One: Enable Fail Transactions

A screenshot of Xcode highlighting the location of the Editor tab in the Xcode menu, the Fail Transactions menu option and the menu that appears where you can select a way to fail a transaction.

In XCode, setup your app to fail transactions with an error of choice.

Step Two: Make a purchase

A screenshot showing a failed purchase in an iOS app.

Run the app and attempt to make a purchase.

Confirm that your code responds as expected to the failed transaction.

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 inquiries@delasign.com 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