MerchantKit

A modern In-App Purchases management framework for iOS developers.

MerchantKit dramatically simplifies the work indie developers have to do in order to add premium monetizable components to their applications. Track purchased products, offer auto-renewing subscriptions, restore transactions, and much more.

Designed for apps that have a finite set of purchasable products, MerchantKit is a great way to add an unlockable ‘pro tier’ to an application, as a one-time purchase or ongoing subscription.

Example Snippets

Find out if a product has been purchased:

let product = merchant.product(withIdentifier: "iap.productidentifier")
print("isPurchased: \(merchant.state(for: product).isPurchased))"

Buy a product:

let task = merchant.commitPurchaseTask(for: purchase)
task.onCompletion = { result in 
    switch result {
        case .succeeded(_):
            print("purchase completed")
        case .failed(let error):
            print("\(error)")
    }
}

task.start()

Get notified when a subscription expires:

<div class="highlight highlight-source-swift position-relative" data-snippet-clipboard-copy-content="public func merchant(_ merchant: Merchant, didChangeStatesFor products: Set) {
if let subscriptionProduct = products.first(where: { $0.identifier == ” subscription.protier” }) { let state = merchant.state(for: subscriptionProduct) switch state { case .isPurchased(let info): print(“subscribed, expires \(info.expiryDate)”) default: print(“does not have active subscription”) } } } “>

public func merchant(_ merchant: Merchant, didChangeStatesFor products: Set) {
    if let subscriptionProduct = products.first(where: { $0.identifier == "subscription.protier" }) {
        let state = merchant.state(for: subscriptionProduct)
        
        switch state {
            case .isPurchased(let info):
                print("subscribed, expires \(info.expiryDate)")
            default:
                print("does not have active subscription")
        }
    }
}