💰 A tiny library for iOS InApp Payment
Swift Ruby
Switch branches/tags
Clone or download
thoughts2binary Added Travis
Latest commit 8c3e848 Jun 10, 2018
Failed to load latest commit information.
Example Added Travis Jun 9, 2018
InAppMachine Added Travis Jun 9, 2018
.gitignore Initial commit Mar 15, 2018
.swift-version Add Swift Version Mar 15, 2018
.travis.yml Added Travis Jun 9, 2018
InAppMachine.podspec Added Travis Jun 9, 2018
LICENSE v1.1.1 May 30, 2018
README.md v1.1.1 May 31, 2018
_Pods.xcodeproj Initial commit Mar 15, 2018



CI Status Version License Platform

A Easy Wrapper Around StoreKit framework for iOS.



  • Updated Documentation
  • Restore InApp Purchase
  • Get Recipts for InApp Purcahse


  • Closure based API for InApp Purcahse
  • Request and Purchase InApp Products


InAppMachine is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'InAppMachine'

Create on iTunes Connect

Step1. Login to your iTunes Account.

Step2. Switch to 'My Apps' and open your app.

Step3. Go to 'Features' section of the app and create InApp Product.


Intialize InAppMachine

Step1: InAppMachine follows singleton, so first you shoud access its singleton object rather than creating one,

import UIKit
import InAppMachine

class ViewController: UIViewController {

    // Add This One
    let inappMachine = InAppMachine.shared

    override func viewDidLoad() {
        // Do any additional setup after loading the view, typically from a nib.



Now, You have to tell InAppMachine about the Product ID(s) which you have made on iTunes connect. Say, you have created a consumable product named 'co.in.greensyntax.restman.developer.program'

So, you have to adopt 'InAppPurchaseSource' protocol and satisfy the stubs (i.e. products).

import UIKit
import InAppMachine

class ViewController: UIViewController, InAppPurchaseSource {

// Change as per your ProductID
var products: [String] = ["co.in.greensyntax.restman.developer.program"]

let inappMachine = InAppMachine.shared

    override func viewDidLoad() {
        // Next, I have set the dataSource with the instance of my object.
        inappMachine.dataSource = self


Request Products

Step3: Now, we'll check wheather our ProductID are valid or not. So, we'll call the request method for checking the validity of product.

inappMachine.requestFor(inAppProducts: { (products) in
    for product in products {
        // Valid Product Deatils
}) { (error) in
    //onError you'll get an error of type InAppError

With these details, you can prepare your Purchase View where you can show Products Details.



And, On Purchase affirmation, you can initiate purchase event with valid Product object. For purchasing, you need an instance of 'InAppProduct' which you got on InApp request call (step3).

self.inappMachine.purcahseFor(product: product, onSuccess: { (transaction: InAppTransaction) in

    //onSuccessfull Transaction

}, onFailed: { (error) in

    //onFailed Transaction



Recipts Validation is usally done to validate the purchase, wheather it's a genuine purchase or not. Say, You have purcahse a InApp product and notifed the your App Server via API that you have purchase this subscription. Now, it's alway a good idea to validate every purchase using reciopts.

// Get Recipts Data to Validate the Purchase
let recipts = inappMachine.getReciptData()


Abhishek Kumar Ravi


InAppMachine is available under the MIT license. See the LICENSE file for more info.