Skip to content
forked from gabrielgarza/monza

Validate App Store In App Purchase receipts including auto-renewable subscriptions

License

Notifications You must be signed in to change notification settings

manishval/monza

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monza

Monza is a ruby gem that makes App Store in app purchase receipt validation and auto-renewable subscription validation easy.

You should always validate receipts on the server, in [Apple's words] (https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW1):

Use a trusted server to communicate with the App Store. Using your own server lets you design your app to recognize and trust only your server, and lets you ensure that your server connects with the App Store server. It is not possible to build a trusted connection between a user’s device and the App Store directly because you don’t control either end of that connection.

Installation

Add this line to your application's Gemfile:

gem 'monza'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install monza

Usage

Basic Usage:

data = "base64 receipt data string"
options = { shared_secret: "your shared secret" }
response = Monza::Receipt.verify(data, options)

# Check if subscription is active
# this checks if latest transaction receipt expiry_date is in today or the future
response.is_subscription_active? # => true or false

# Check most recent expiry date
response.latest_expiry_date # => DateTime

# Receipt object
# See Receipt class
response.receipt

# Receipt In App Transactions
# Returns array of TransactionReceipt objects, see TransactionReceipt class
response.receipt.in_app

# Receipt Latest Transactions List, use these instead if in_app to ensure you always have the latest
# Returns array of TransactionReceipt objects, see TransactionReceipt class
response.latest_receipt_info

# Latest receipt base64 string
response.latest_receipt

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/gabrielgarza/monza. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

TODO:

  • Need help with testing using rspec

License

The gem is available as open source under the terms of the MIT License.

About

Validate App Store In App Purchase receipts including auto-renewable subscriptions

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 99.4%
  • Shell 0.6%