App Store Receipt Validation

Related tags

Utility Kvitto
Overview

Kvitto

"Kvitto, it means Receipt in Swedish. The trend of using Swedish words for libraries is pretty big" -- Hugo Tunius via Twitter

Allows parsing an validation of iTunes App Store receipts. Receipts also contain the In App Purchase receipts. For auto-renewable subscriptions the subscription expiration date is available.

Documentation

Look at the included Demo app's ViewController to see how to load and validate a Store receipt locally. This sample is in Objective-C to demonstrate the Kvitto - although written in Swift - can also be used from Objective-C code.

License

It is open source and covered by a standard 2-clause BSD license. That means you have to mention Cocoanetics as the original author of this code and reproduce the LICENSE text inside your app.

You can purchase a Non-Attribution-License for 75 Euros for not having to include the LICENSE text.

We also accept sponsorship for specific enhancements which you might need. Please contact us via email for inquiries.

Comments
  • How to Determine Eligibility?

    How to Determine Eligibility?

    Hi,

    i try to determine eligibility for an introductory offer. Apple's docs say:

    In the receipt, check the values of the is_trial_period and the is_in_intro_offer_period for all in-app purchase transactions. If either of these fields are true for a given subscription, the user is not eligible for an introductory offer

    I did not find a way to read the is_trial_period or the is_in_intro_offer_period values from DTInAppPurchaseReceipt? Is there a way to access them?

    Kind regards, Markus

    opened by MacMark 13
  • Support of StoreKitTest receipts

    Support of StoreKitTest receipts

    In Xcode 12 Apple added a new way of testing In-App purchases (see Introducing StoreKit Testing in Xcode WWDC 2020 talk for more info). The new method relies on receipts signed with a different private key than ordinary receipts. During an attempt to parse such a receipt I get an "Indefinite Length form encounted, not implemented" error inside DTASN1Parser. Can you please add the support of StoreKitTest receipts in Kvitto? I can send you an example of such a receipt over an email if you need one. This functionality was implemented in TPInAppReceipt, so you can check it for reference.

    opened by RenGate 7
  • Unit tests are failing with DTFoundation version 1.7.18

    Unit tests are failing with DTFoundation version 1.7.18

    Hey,

    We recently updated swift packages in our app and with the updates came DTFoundation 1.7.18. In our tests, receipt parsing stopped working in our app with combination of Kvitto (version 1.0.6) and DTFoundation (version 1.7.18). On older version 1.7.17 receipts are parsed successfully and unit tests are all green as well.

    opened by jlajlar 5
  • Receipt parsing fails due to format changes

    Receipt parsing fails due to format changes

    Since a few days ago, some of the App Receipts that are generated by iOS have a slightly different format and Kvitto fails to parse these receipts properly. In my app, around 50% of the app receipts are affected. I'm already using Kvitto in my app since about a year, but this problem occurred for the first time on September 24.

    It seems that the issue is that sometimes the date format contains fractional seconds, so for example a date looks like this

    2020-09-27T12:07:19.686Z
    

    instead of this:

    2020-09-27T12:07:19Z
    

    The method _dateFromRFC3339String() fails to parse the former date string, so _dateFromData() throws and Receipt.init?(contentsOfURL) returns nil.

    It's possible that there are some more changes to the format - I'm still investigating. If I find time in the next days, I'll prepare a pull request with a fix.

    opened by Theome 5
  • Will Local receipt validation require AppStore authentication?

    Will Local receipt validation require AppStore authentication?

    Hi - I'm interested in using your library for local receipt validation before sending it up to my API. I was wondering though. During the receipt validation flow, will the dreaded IAP authentication modals pop up? I have a requirement to not show those to the user.

    opened by ankitkapasi 5
  • ld: framework not found DTFoundation for architecture ...

    ld: framework not found DTFoundation for architecture ...

    Using Carthage to build Kvitto, in Cartfile: github "Cocoanetics/Kvitto" "develop"

    When build with my iPhone or Generic iOS Device, got the error: ld: framework not found DTFoundation for architecture arm64 sometimes its: ld: framework not found DTFoundation for architecture armv7

    When build with Simulators, got the error: ld: framework not found DTFoundation for architecture x86_64

    However, the project in Carthage/Checkouts/Kvitto always build success. I found a related issue in DTFoundation https://github.com/Cocoanetics/DTFoundation/issues/109 It looks like something wrong with the project setting for Carthage usage.

    opened by aalenliang 5
  • Error in parseData?

    Error in parseData?

    Hey Oliver,

    Kvitto looks cool. :-) So I wanted to use it and included it as a CocoaPod. In Dev mode, I parse a receipt, but on line 126 in Receipt.swift I get an error:

    guard let rootArray = DTASN1Serialization.objectWithData(data) as? [[AnyObject]]

    According to lldb:

    po DTASN1Serialization.objectWithData(data).dynamicType
       Swift.Optional<Swift.AnyObject>
    

    If I rewrite this a bit:

    let _rootArray = DTASN1Serialization.objectWithData(data)
    guard let rootArray = _rootArray as? [[AnyObject]]
    

    I get to know that _rootArray is an NSArray? with a count of 2 where [0] is an NSString and [1] is an Array. The String [0] in my case was "1.2.840.113549.1.7.2", not sure what this is. The NSArray [1] has a count of 1, another NSArray, with 5 elements. I dove into it further but wasn't sure what to make out of it. I've attached the po of _rootArray: https://www.dropbox.com/s/moalpyplpbtcfnk/receipt.txt?dl=0

    Do you have any pointers to what I should do?

    Cheers

    Nik
    
    opened by niklassaers 5
  • Project is not building with Xcode 12.5 beta 2 (12E5234g)

    Project is not building with Xcode 12.5 beta 2 (12E5234g)

    DTFoundation is not building anymore with the new Xcode using SPM. On the other hand it would be nice to make Kvitto dependency free without DTFoundation.

    Screenshot 2021-02-17 at 09 16 51
    opened by MarvinNazari 4
  • Migrate to swift 4.0

    Migrate to swift 4.0

    1. project migrated to swift 4.0
    2. DTFoundation updated to 1.7.13
    3. podspec updated to 1.0.3
    4. access quantity and webOrderLineItemIdentifier in objectiveC suppor added
    opened by thaya-cameraxis 3
  • DateFormatter may cause performance problems and should be reused

    DateFormatter may cause performance problems and should be reused

    This blog post by Sarun has made me aware of the poor performance of DateFormatter if it isn't reused. If these estimations are correct, each call to _dateFromRFC3339String in Functions.swift can take more than 100ms (initialization of a date formatter plus updating its locale and time zone).

    As an App Store receipt can easily contain dozens of dates, and Kvitto might be used on the main thread (as in the example project), there's a real risk that this performance issue can lead to watchdog terminations.

    Initialization and configuration of the DateFormatter should be done only once.

    opened by Theome 1
  • Check for actualSequence.count == 5 may fail as Apple doesn't always supply 5 elements.

    Check for actualSequence.count == 5 may fail as Apple doesn't always supply 5 elements.

    Thank you for the great library!

    Wanted to give you a heads up on the following line of code: https://github.com/Cocoanetics/Kvitto/blob/59c95c14bf3859c814df8594b6d5679ab4185b75/Core/Source/PKCS7Container.swift#L48

    At some point this year Apple started to supply 3 items in this sequence. I changed it to actualSequence.count > 2 as there is no need to use anything from it above [2]. Since then it is working alright.

    This was the issue both in production receipts and sandbox in August 2020. I'm not sure if this issue still persists. But the above change will relax the requirement on the sequence to the data you really need, not stricter.

    Thank you again! Looks like Apple is fiddling around with the receipt lately, hope this input will help you and others.

    opened by staninprague 1
  • Podspec push warnings/notes

    Podspec push warnings/notes

    I ignored these warnings publishing 1.0.5:

        - NOTE  | [Kvitto/Core] xcodebuild:  note: Using new build system
        - NOTE  | [Kvitto/Core] xcodebuild:  note: Building targets in parallel
        - NOTE  | [Kvitto/Core] xcodebuild:  note: Using codesigning identity override: -
        - NOTE  | [Kvitto/Core] xcodebuild:  note: Planning build
        - NOTE  | [Kvitto/Core] xcodebuild:  note: Constructing build description
        - NOTE  | [Kvitto/Core] xcodebuild:  warning: Skipping code signing because the target does not have an Info.plist file and one is not being generated automatically. (in target 'App' from project 'App')
        - NOTE  | [Kvitto/Core] xcodebuild:  warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'DTFoundation' from project 'Pods')
    

    I need to find out how to generate HTML documentation and how to build that on my Mac mini Server...

    The message about deployment target being less than 9 is odd, as the spec has the iOS deployment target set to 9.

    opened by odrobnik 0
Releases(1.0.6)
  • 1.0.6(Jul 12, 2021)

    Updated a syntax error in DTFoundation that would make it not build on Xcode beta

    Updated and Re-released on July 12th because of an incompatibility with updates to DTASN.1

    Source code(tar.gz)
    Source code(zip)
  • 1.0.5(Oct 19, 2020)

    • NEW: Added support for indefinite length encoding for containers
    • NEW: Added support for decoding date strings with a UTC offset instead of Z.

    Announcement: https://www.cocoanetics.com/2020/10/kvitto-1-0-5/

    Source code(tar.gz)
    Source code(zip)
  • 1.0.4(Oct 9, 2020)

    • NEW: Support Swift Package Manager
    • FIXED: dates with fractional seconds would not be parsed
    • FIXED: Relax check for sequence in root of PKCS7 container, as Apple might sometimes supply only 3 elements instead of 5

    Announcement: https://www.cocoanetics.com/2020/09/kvitto-1-0-4/

    Source code(tar.gz)
    Source code(zip)
  • 1.0.3(Sep 28, 2020)

  • 1.0.2(Mar 29, 2017)

  • 1.0.1(Dec 29, 2015)

  • 1.0.0(Oct 7, 2015)

Owner
Cocoanetics
Cocoanetics
swift-highlight a pure-Swift data structure library designed for server applications that need to store a lot of styled text

swift-highlight is a pure-Swift data structure library designed for server applications that need to store a lot of styled text. The Highlight module is memory-efficient and uses slab allocations and small-string optimizations to pack large amounts of styled text into a small amount of memory, while still supporting efficient traversal through the Sequence protocol.

kelvin 4 Aug 14, 2022
StoredIn is a simple property wrapper library to store any value in anywhere

StoredIn StoredIn is a simple property wrapper library to store any value in anywhere. Installation Please use the Swift Package Manager. dependencies

Henrique Sasaki Yuya 2 Jul 4, 2022
A utility that reminds your iPhone app's users to review the app written in pure Swift.

SwiftRater SwiftRater is a class that you can drop into any iPhone app that will help remind your users to review your app on the App Store/in your ap

Takeshi Fujiki 289 Dec 12, 2022
Mac app to change .ipa file app icons and display names

IPAEdit Mac app to change .ipa file app icon, display name, and app version to avoid updates Compatible with macOS 10.11+ Install To install either cl

Ethan Goodhart 23 Dec 28, 2022
A Flutter plugin (platform channel with Swift) to get the current app name and also bring our app to the front.

window_to_front A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized package th

Minas Giannekas 1 Nov 13, 2021
A way to easily add Cocoapod licenses and App Version to your iOS App using the Settings Bundle

EasyAbout Requirements: cocoapods version 1.4.0 or above. Why you should use Well, it is always nice to give credit to the ones who helped you ?? Bonu

João Mourato 54 Apr 6, 2022
This iOS framework allows settings to be in-app in addition to or instead of being in the Settings app.

InAppSettingsKit InAppSettingsKit (IASK) is an open source framework to easily add in-app settings to your iOS or Catalyst apps. Normally iOS apps use

Ortwin Gentz, FutureTap 3.1k Jan 2, 2023
TypeStyle is a handy app for iPhone and iPad that generates text using different styles and decorations. It is a native Swift iOS app.

TypeStyle TypeStyle is a handy app for iPhone and iPad that generates text using different styles and decorations. It is a native Swift iOS app. Featu

Eugene Belinski 31 Dec 14, 2022
This is a command line tool to extract an app icon. this sample will extract the icon 16x16 from Safari app.

?? X-BundleIcon This is a command line tool to extract an app icon. this sample will extract the icon 16x16 from Safari app. xbi com.apple.Safari 16 /

Rui Aureliano 3 Sep 1, 2022
Add “Launch at Login” functionality to your macOS app in seconds

LaunchAtLogin Add “Launch at Login” functionality to your macOS app in seconds It's usually quite a convoluted and error-prone process to add this. No

Sindre Sorhus 1.3k Jan 6, 2023
Implementation of x-callback-url (Inter app communication) in swift

CallbackURLKit - Inter app communication Starting to integrate URL scheme in an app, why not be compliant with x-callback-url. CallbackURLKit.register

Eric Marchand 318 Nov 14, 2022
Generate a privacy policy for your iOS app

PrivacyFlash Pro To easily run PrivacyFlash Pro get the latest packaged release. Learn more about PrivacyFlash Pro in our research paper. PrivacyFlash

privacy-tech-lab 141 Dec 22, 2022
Tweak your iOS app without recompiling!

SwiftTweaks Adjust your iOS app on the fly without waiting to re-compile! Your users won’t see your animation study, Sketch comps, or prototypes. What

Khan Academy 1.4k Dec 28, 2022
Showcase new features after an app update similar to Pages, Numbers and Keynote.

WhatsNew Description WhatsNew automatically displays a short description of the new features when users update your app. This is similar to what happe

Patrick Balestra 1.5k Jan 4, 2023
WhatsNewKit enables you to easily showcase your awesome new app features.

WhatsNewKit enables you to easily showcase your awesome new app features. It's designed from the ground up to be fully customized to your needs. Featu

Sven Tiigi 2.8k Jan 3, 2023
A simple Pokedex app written in Swift that implements the PokeAPI, using Combine and data driven UI.

SwiftPokedex SwiftPokedex is a simple Pokedex app written by Viktor Gidlöf in Swift that implements the PokeAPI. For full documentation and implementa

Viktor G 26 Dec 14, 2022
Helpful extensions for iOS app development 🚀

ExtensionKit includes many extensions, from getting the user location with a deterministic Combine API to a shimmer loading animation, to keyboard notification updates, bottom sheet and much much more. Check out the docs below or install the library with SPM to try it out.

Gary Tokman 110 Oct 31, 2022
Dedicated settings app for accessing tweaks preference bundles.

Tweak Settings A dedicated settings app for tweak preferences Author Dana Buehre (CreatureSurvive) [email protected] © Dana Buehre (CreatureSurviv

Dana Buehre 29 Dec 19, 2022
I needed to detect idle mode on a SwiftUI app for a kiosk, so I did it.

Inactivity I needed to detect idle mode on a SwiftUI app for a kiosk, so I did it. Usage Important: You must set the Principal class of your app to In

Helio Tejedor 16 Dec 19, 2022