Latest 1.0.0
Homepage https://github.com/rpzzzzzz/SwiftInAppPurchase
License Apache
Platforms ios 8.0, requires ARC
Frameworks StoreKit
Authors

CI Status
Version
License
Platform

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

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

pod "SwiftInAppPurchase"

Author

Rawd, [email protected]

License

SwiftInAppPurchase is available under the Apache 2.0 license. See the LICENSE file for more info.

Production Mode

SwiftInAppPurchase.sharedInstance.setProductionMode(false)

Request Products

var productIden = Set<String>()
productIden.insert("com.irawd.test.30d")

let iap = SwiftInAppPurchase.sharedInstance

iap.requestProducts(productIden) { (products, invalidIdentifiers, error) -> () in

}

Purchase

let iap = SwiftInAppPurchase.sharedInstance
iap.addPayment("com.irawd.test.30d", userIdentifier: nil) { (result) -> () in

    switch result{
    case .Purchased(let productId,let transaction,let paymentQueue):

        paymentQueue.finishTransaction(transaction)
    case .Failed(let error):
        print(error)
    default:
        break
    }            
}

RefreshReceipt

let iap = SwiftInAppPurchase.sharedInstance
iap.refreshReceipt { (error) -> () in
    print(error)
}

VerifyReceipt

let iap = SwiftInAppPurchase.sharedInstance
iap.verifyReceipt(nil) { (receipt, error) -> () in
    print(receipt)
    print(error)
}

Restore

let iap = SwiftInAppPurchase.sharedInstance
iap.restoreTransaction(nil) { (result) -> () in
    switch result{
    case .Restored(let productId,let transaction,let paymentQueue) :

        paymentQueue.finishTransaction(transaction)
    case .Failed(let error):
        print(error)

    default:
    break
    }
}       

CheckIncompleteTransaction

let iap = SwiftInAppPurchase.sharedInstance
iap.checkIncompleteTransaction { (result) -> () in
    switch result{
    case .Purchased(let productId,let transaction,let paymentQueue):
        paymentQueue.finishTransaction(transaction)
    case .Restored(let productId,let transaction,let paymentQueue) :

        paymentQueue.finishTransaction(transaction)
    default:
        break
    }
}

Latest podspec

{
    "name": "SwiftInAppPurchase",
    "version": "1.0.0",
    "summary": "A swift wrapper for iOS in app purchases.",
    "description": "This CocoaPod provide the ability of in app purchase (IAP)",
    "homepage": "https://github.com/rpzzzzzz/SwiftInAppPurchase",
    "license": "Apache",
    "authors": {
        "Rawd": "[email protected]"
    },
    "source": {
        "git": "https://github.com/rpzzzzzz/SwiftInAppPurchase.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*",
    "resource_bundles": {
        "SwiftInAppPurchase": [
            "Pod/Assets/*.png"
        ]
    },
    "frameworks": "StoreKit"
}

Pin It on Pinterest

Share This