Sha256: fce44b467e820b6ce03b0ecb64538ccc803e1a1c6d01476cfc9e45bbb5256fc0
Contents?: true
Size: 1.83 KB
Versions: 10
Compression:
Stored size: 1.83 KB
Contents
#!/usr/bin/env ruby require 'venice' require 'commander/import' require 'terminal-table' HighLine.track_eof = false # Fix for built-in Ruby Signal.trap("INT") {} # Suppress backtrace when exiting command program :version, Venice::VERSION program :description, 'A command-line interface for verifying Apple In-App Purchase receipts' program :help, 'Author', 'Mattt Thompson <m@mattt.me>' program :help, 'Website', 'https://github.com/mattt' program :help_formatter, :compact default_command :help command :verify do |c| c.syntax = 'iap verify RECEIPT' c.summary = 'Verifies an In-App Purchase Receipt' c.description = '' c.option '-S', '--[no-]sandbox', 'Use sandbox verification webservice' c.option '-p', '--secret SECRET', 'Use a shared secret for auto-renewable subscription receipts' c.example 'description', 'iap verify /path/to/receipt [--secret shared_secret]' c.action do |args, options| say_error "Missing receipt argument" and abort unless file = args.first say_error "Receipt file does not exist" unless File.exist?(file) client = options.sandbox ? Venice::Client.development : Venice::Client.production client.shared_secret = options.secret if options.secret begin receipt = client.verify!(File.read(file)) table = Terminal::Table.new :title => "Receipt" do |t| hash = receipt.to_h hash.keys.sort.each do |key| next if key == :in_app t << [key, hash[key]] end if hash[:in_app] index = 0 hash[:in_app].each do |iap| index += 1 t << :separator t << [:in_app, index] iap.keys.sort.each do |key| t << [" - #{key}", iap[key]] end end end end puts table rescue => error say_error error.message and abort end end end
Version data entries
10 entries across 10 versions & 4 rubygems