---
title: "#219: Simpler In-App Purchases with SwiftyStoreKit  🏪"
url: https://littlebitesofcocoa.com/219-simpler-in-app-purchases-with-swiftystorekit
author: Jake Marsh
published: 2016-03-24
topics: ["Libraries","UIKit"]
description: "In-App Purchases have become a very important part of our business. Adding them to an app can involve quite a bit of boilerplate code though."
---

# #219: Simpler In-App Purchases with SwiftyStoreKit  🏪

By Jake Marsh, March 24, 2016. HTML: https://littlebitesofcocoa.com/219-simpler-in-app-purchases-with-swiftystorekit

_In-App Purchases_ have become a very important part of our business. Adding them to an app can involve quite a bit of boilerplate code though. Today we'll look at [SwiftyStoreKit](https://github.com/bizz84/SwiftyStoreKit), a framework from [Andrea Bizzotto](https://github.com/bizz84) that can help.

[SwiftyStoreKit](https://github.com/bizz84/SwiftyStoreKit) provides a few static functions we can use to easily implement all the common _In-App Purchase_ tasks like getting the info about our "products" from Apple, purchasing, restoring, and even receipt verification. Let's take a look:

``` swift
SwiftyStoreKit.retrieveProductInfo("com.littlebitesofcocoa.products.volume1") { result in
  switch result {
    case .Success(let product):
      let priceString = NSNumberFormatter.localizedStringFromNumber(product.price, numberStyle: .CurrencyStyle)
      print("Product: \(product.localizedDescription), Price: \(priceString)")

    case .Error(let error): print("Error: \(error)")
  }
}
```

We pass in the **product identifier**, and supply a **closure** that can process the result. If successful, we use **NSNumberFormatter** ([Bite #182](https://littlebitesofcocoa.com/182)) to print a nice looking summary of the product.

From here, we just need to wire up the other functions [SwiftyStoreKit](https://github.com/bizz84/SwiftyStoreKit) provides like purchaseProduct, restorePurchases, and verifyReceipt.

More info about _SwiftyStoreKit_ can be found at [git.io/swiftystorekit](http://git.io/swiftystorekit)
