All Projects → tikhop → Tpinappreceipt

tikhop / Tpinappreceipt

Licence: mit
Reading and Validating In App Purchase Receipt Locally.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Tpinappreceipt

DYFStoreKit
([Swift] https://github.com/chenxing640/DYFStore) A lightweight and easy-to-use iOS library for In-App Purchases (Objective-C). DYFStoreKit uses blocks and notifications to wrap StoreKit, provides receipt verification and transaction persistence and doesn't require any external dependencies.
Stars: ✭ 52 (-82.95%)
Mutual labels:  payment, purchase
Orsserialport
Serial port library for Objective-C and Swift macOS apps
Stars: ✭ 609 (+99.67%)
Mutual labels:  osx, cocoapods
Xcake
🍰 Describe Xcode projects in a human readable format and (re)generate one on demand.
Stars: ✭ 549 (+80%)
Mutual labels:  osx, cocoapods
Device
Light weight tool for detecting the current device and screen size written in swift.
Stars: ✭ 1,503 (+392.79%)
Mutual labels:  osx, cocoapods
Fire
🔥A delightful HTTP/HTTPS networking framework for iOS/macOS/watchOS/tvOS platforms written in Swift.
Stars: ✭ 243 (-20.33%)
Mutual labels:  osx, cocoapods
Criollo
A powerful Cocoa web framework and HTTP server for macOS, iOS and tvOS.
Stars: ✭ 229 (-24.92%)
Mutual labels:  osx, cocoapods
Webhere
HTML scraping for Objective-C.
Stars: ✭ 16 (-94.75%)
Mutual labels:  osx, cocoapods
Mfcard
Easily integrate Credit Card payments module in iOS App. Swift 4.0
Stars: ✭ 356 (+16.72%)
Mutual labels:  payment, cocoapods
EnhanceDiskUtility
SIMBL plugin for Disk Utility that aims to enable Verify / Repair Permissions support
Stars: ✭ 17 (-94.43%)
Mutual labels:  verify, osx
Web3.swift
A pure swift Ethereum Web3 library
Stars: ✭ 295 (-3.28%)
Mutual labels:  cocoapods
Gpgsync
🔒 GPG Sync is designed to let users always have up-to-date public keys for other members of their organization
Stars: ✭ 301 (-1.31%)
Mutual labels:  osx
Attributedstring
基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.
Stars: ✭ 294 (-3.61%)
Mutual labels:  cocoapods
Anyformatkit
Simple text formatting in Swift
Stars: ✭ 296 (-2.95%)
Mutual labels:  cocoapods
Mevfloatingbutton
An iOS drop-in UITableView, UICollectionView and UIScrollView superclass category for showing a customizable floating button on top of it.
Stars: ✭ 301 (-1.31%)
Mutual labels:  cocoapods
Opencore Vanilla Desktop Guide
Host for files for the OpenCore Vanilla Desktop Guide
Stars: ✭ 299 (-1.97%)
Mutual labels:  osx
Lthradiobutton
A radio button with a pretty animation
Stars: ✭ 303 (-0.66%)
Mutual labels:  cocoapods
Netfox
A lightweight, one line setup, iOS / OSX network debugging library! 🦊
Stars: ✭ 3,188 (+945.25%)
Mutual labels:  cocoapods
Socket.io Tester
Deprecated: An electron app that lets you connect to a socket.io server and subscribe to a certain topic and/or lets you send socket messages to the server
Stars: ✭ 297 (-2.62%)
Mutual labels:  osx
Xlactioncontroller
Fully customizable and extensible action sheet controller written in Swift
Stars: ✭ 3,228 (+958.36%)
Mutual labels:  cocoapods
Functionkit
A framework for functional types and operations designed to fit naturally into Swift.
Stars: ✭ 302 (-0.98%)
Mutual labels:  cocoapods

TPInAppReceipt

Swift CocoaPods Compatible Swift Package Manager compatible Platform GitHub license

A lightweight library for reading and validating Apple In App Purchase Receipt locally.

Features

  • [x] Extract all In-App Receipt Attributes
  • [x] Hash Verification
  • [x] Verify Bundle Version and Identifiers
  • [x] Signature Verification

Installation

CocoaPods

To integrate TPInAppReceipt into your project using CocoaPods, specify it in your Podfile:

platform :ios, '9.0'

target 'YOUR_TARGET' do
    use_frameworks!

    pod 'TPInAppReceipt'
end

Then, run the following command:

$ pod install

In any swift file you'd like to use TPInAppReceipt, import the framework with import TPInAppReceipt.

Swift Package Manager

To integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/tikhop/TPInAppReceipt.git", .upToNextMajor(from: "3.0.0"))

Then, specify "TPInAppReceipt" as a dependency of the Target in which you wish to use TPInAppReceipt.

Lastly, run the following command:

swift package update

Requirements

  • iOS 9.0+ / OSX 10.11+
  • Swift 5.3+

Usage

Working With a Receipt

InAppReceipt is an object to incapsulate all necessary getters from a receipt payload and provides a comprehensive API for reading and validating in app receipt and related purchases.

Initializing Receipt

do {
  /// Initialize receipt
  let receipt = try InAppReceipt.localReceipt() 
  
  // let receiptData: Data = ...
  // let receipt = try InAppReceipt.receipt(from: receiptData)
  
} catch {
  print(error)
}


Refreshing/Requesting Receipt

Use this method to request a new receipt if the receipt is invalid or missing.

InAppReceipt.refresh { (error) in
  if let err = error
  {
    print(err)
  }else{
    initializeReceipt()
  }
}

Reading Receipt

/// Base64 Encoded Receipt
let base64Receipt = receipt.base64
  
/// Initialize receipt
let receipt = try! InAppReceipt.localReceipt() 

/// Check whether receipt contains any purchases
let hasPurchases = receipt.hasPurchases

/// All auto renewable `InAppPurchase`s,
let purchases: [InAppPurchase] = receipt.autoRenewablePurchases 

/// all ACTIVE auto renewable `InAppPurchase`s,
let activePurchases: [InAppPurchase] = receipt.activeAutoRenewableSubscriptionPurchases 

Useful methods

// Retrieve Original TransactionIdentifier for Product Name
receipt.originalTransactionIdentifier(ofProductIdentifier: subscriptionName)

// Retrieve Active Auto Renewable Subscription's Purchases for Product Name and Specific Date
receipt.activeAutoRenewableSubscriptionPurchases(ofProductIdentifier: subscriptionName, forDate: Date())

// Retrieve All Purchases for Product Name
receipt.purchases(ofProductIdentifier: subscriptionName)

Validating Receipt

/// Verify all at once

do {
    try r.verify()
} catch IARError.validationFailed(reason: .hashValidation) 
{
    // Do smth
} catch IARError.validationFailed(reason: .bundleIdentifierVerification) 
{
    // Do smth
} catch IARError.validationFailed(reason: .signatureValidation) 
{
    // Do smth
} catch {
    // Do smth
}

/// Verify hash 
try? r.verifyHash()

/// Verify bundle identifier and version
try? r.verifyBundleIdentifierAndVersion()

/// Verify signature
try? r.verifySignature()

Essential Reading

License

TPInAppReceipt is released under an MIT license. See LICENSE for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].