Giter Club home page Giter Club logo

itunes-receipt's Introduction

itunes-receipt

Handle iTunes In App Purchase Receipt Verification.

Installation

gem install itunes-receipt

Usage

require 'itunes/receipt'

# pass Base64 encoded raw receipt data which you received from your iOS app
receipt = Itunes::Receipt.verify! 'ewoJInNpZ25hdHVyZSIgPSAi...'
receipt.product_id     # => 'com.example.products.100gems'
receipt.transaction_id # => '1234567890'
 :

See lib/itunes/receipt.rb for more attributes.

If you want to accept iTunes sandbox receipts, do like this. With allow_sandbox_receipt option specified, this gem post given receipt data to iTunes production first, and when iTunes production tells it’s sandbox receipt, re-send it to iTunes sandbox again automatically. Without this option, this gem just raises an exception.

receipt = Itunes::Receipt.verify! 'ewoJInNpZ25hdHVyZSIgPSAi...', :allow_sandbox_receipt
receipt.sandbox? # => true/false

If you want to accept ONLY iTunes sandbox receipts (in your stable server etc.), call Itunes.sandbox! somewhere before you call Itunes::Receipt.verify!. Then all verification call after that goes to iTunes sandbox, until you do Itunes.sandbox = false.

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2011 nov matake. See LICENSE for details.

itunes-receipt's People

Contributors

birkirb avatar burnettk avatar clupprich avatar kaomte avatar nov avatar philipgiuliani avatar r4m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

itunes-receipt's Issues

JSON Conversion Missing Data

When converting to JSON, many of the fields are missing, most notably the in app purchases are missing.

The json conversion method was added in b991925.

Was there a specific reason for adding the as_json method? Removing the as_json method seems to resolve the issue.

RestClient::SSLCertificateNotVerified Error

I've been getting these errors in production. I've fixed the issue on a custom branch of mine by swapping out RestClient for Faraday.

I, [2018-03-01T15:53:16.455400 #19005] INFO -- : Celluloid 0.17.2 is running in BACKPORTED mode. [ http://git.io/vJf3J ] Loading development environment (Rails 4.2.5) irb(main):001:0> require 'itunes' => false irb(main):002:0> Itunes::Receipt.verify!({}) RestClient::SSLCertificateNotVerified: SSL_connect returned=1 errno=0 state=error: certificate verify failed: from /Users/kaom/.rbenv/versions/2.1.10/lib/ruby/gems/2.1.0/gems/rest-client-1.8.0/lib/restclient/request.rb:445:in rescue in transmit'`

Add support for `cancellation_date` field

It would be great if the receipt object would expose the cancellation_date field for auto-renewable subscriptions!

From the receipt fields docs:

For a transaction that was canceled by Apple customer support, the time and date of the cancellation. Treat a canceled receipt the same as if no purchase had ever been made.

Where to set Shared secrent for Auto renewal subscriptions?

This gem is working perfectly for non renewal subscriptions.

For auto renewal subscriptions verification fails. Auto renewal subscription needs shared secret but i don't know where to set My Shared Secret in the code.

Can you please help me....

recipt validations

i have some exceptions since we put it in production. Basically it works i checked with my live app account etc. But for some receipts i have these errors :

 no implicit conversion of Symbol into Integer
 itunes-receipt (1.0.0) lib/itunes/receipt.rb:54:in `[]'

do you have any ideas you want me to send you a sample receipt?

`expires_date` field is invalid for auto-renewable subscriptions

When I verify receipts for auto-renewable subscriptions, the value for expires_date is wrong:

receipt_data = "..." # receipt for auto-renewable subscription
receipt = Itunes::Receipt.verify!(receipt_data, true)
receipt.expires_date
# => "1969-12-31 16:00:02.000000000 -08:00" (UTC epoch + 2 seconds?)

I think Receipt#initialize is parsing expires_date as milliseconds, but Apple's validator returns it as three fields (date, date_ms, and date_pst), similar to how it returns purchase_date. Snippet of a raw response from the validator:

{
  "receipt": {
    "in_app": [
      {
        ...,
        "purchase_date": "2015-08-01 11:47:43 Etc/GMT",
        "purchase_date_ms": "1438429663000",
        "purchase_date_pst": "2015-08-01 04:47:43 America/Los_Angeles",
        "expires_date": "2015-09-01 11:47:43 Etc/GMT",
        "expires_date_ms": "1441108063000",
        "expires_date_pst": "2015-09-01 04:47:43 America/Los_Angeles",

It looks like at some point Apple standardized how they return their date fields, but expires_date is being parsed as ms instead of a date string.

JSON Conversion is broken

I currently get this error:

"ArgumentError:
wrong number of arguments (1 for 0)"

I'm running on ruby 1.9.3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.