Project

storekit

0.0
No commit activity in last 3 years
No release in over 3 years
Validate In App Purchase receipts against the Apple App Store
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

 Project Readme

storekit_ruby

Build Status Code Climate Gem Version

This is a no frills gem for verifying Apple App Store In App Purchase receipts.

Installation

$ gem install storekit

Usage

require 'storekit'

data = "<Base64-Encoded Receipt Data>"

# This client tries to validate against the production endpoint first. If it
# fails because of error 21007, it automatically validates against the sandbox
# endpoint.
client = StoreKit::FallbackClient.new
client.shared_secret = "really secret string"

begin
  receipt = client.verify! data

  # The raw data
  p receipt.receipt_data

  # Just the IAP receipts
  p receipt.iap_receipts

  # Hash, mapping from original TX IDs to array of transactions sorted in
  # ascending order by purchase date.
  p receipt.receipt_chains

  # Do whatever you need to do to store the purchase state...
rescue StoreKit::ValidationError => e
  # ¯\_(ツ)_/¯
  raise 'no soup for you!'
end

License

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