Encodes receipt data into iTunes encoded receipts and exports as appStoreReceiptURL or transactionReceipt formats.
Install from the command line:
$ gem install itunes_receipt_encoder
Or include it in your Gemfile:
gem 'itunes_receipt_encoder'
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
Returns a unified style receipt, corresponding to the appStoreReceiptURL.
: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.
Returns a transaction style receipt, corresponding to the transactionReceipt.
: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.
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
$ 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.