No commit activity in last 3 years
No release in over 3 years
Encodes receipt data into iTunes encoded receipts and exports as appStoreReceiptURL or transactionReceipt formats.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

iTunes Receipt Encoder

Encodes receipt data into iTunes encoded receipts and exports as appStoreReceiptURL or transactionReceipt formats.

Code Climate Test Coverage Build Status Gem Version Dependency Status

Install

Install from the command line:

$ gem install itunes_receipt_encoder

Or include it in your Gemfile:

gem 'itunes_receipt_encoder'

Usage

require 'itunes_receipt_encoder'

encoder = ItunesReceiptEncoder.new(
  bundle_id: 'com.mbaasy.ios',
  environment: 'Production',
  application_version: '1.0',
  original_application_version: '1.0',
  creation_date: Time.now,
  in_app:
  [{
    quantity: 1,
    product_id: 'premium',
    transaction_id: 582591442087453,
    original_transaction_id: 582591442087453,
    purchase_date: Time.now,
    original_purchase_date: Time.now,
    expires_date: Time.now + (60 * 60 * 24 * 30),
    web_order_line_item_id: 566905420318744
  }, {
    quantity: 1,
    product_id: 'extra-life',
    transaction_id: 970762356111308,
    original_transaction_id: 223608664143082,
    purchase_date: Time.now,
    original_purchase_date: Time.now
  }]
)

encoder.to_unified # => appStoreReceiptURL receipt

encoder.to_transaction # => transactionReceipt receipt

encoder.to_unified([options = {}])

Returns a unified style receipt, corresponding to the appStoreReceiptURL.

Options:

:cert - SSL certicicate to create the P7 payload.

:key - SSL private key to create the P7 payload.

:raw - Boolean, if true returns the raw P7 payload, otherwise returns a encoded Base64 string.

encoder.to_transaction([options = {}])

Returns a transaction style receipt, corresponding to the transactionReceipt.

Options:

:raw - Boolean, if true returns the raw plist, otherwise returns a Base64 encoded string.

:index - Integer, if set will use the specific index in the in_app array for the receipt, otherwise it will use the first one.

:no_ms_dates - Boolean, if true it will exclude millisecond timestamps from the result.

:no_pst_dates - Boolean, if true it will exclude PST timestamps from the results.

Command line

You can use this library to generate files on the command line too:

Usage: itunes_receipt_encoder [options] file

file: receipt data as JSON

Options:
    -s, --style STYLE                iTunes receipt output style
                                     unified or transaction
                                     defaults to unified
    -r, --raw                        Return raw ouptput instead of Base64

Unified receipt style options:
    -c, --cert FILE                  SSL certificate file to create P7 payload
    -k, --key FILE                   SSL private key file to create P7 payload

Transaction receipt style options:
    -i, --index N                    Use the specific index from in_app
    -m, --no-ms-dates                Exclude millisecond timestamps from results
    -p, --no-pst-dates               Exclude PST timestamps from results

Additional options:
    -h, --help                       Show this message
    -v, --version                    Display the version number
Example:
$ itunes_receipt_encoder -s transaction path/to/transaction.json > path/to/save.txt

Copyright 2015 mbaasy.com. This project is subject to the MIT License.