Sha256: 3b87991cf6d6bb63f4a85e88c4ad572aa4013cf0020b0c0c09746e64e0581e2b

Contents?: true

Size: 654 Bytes

Versions: 3

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

require 'base64'

require 'apple_receipt/next_step_parser'
require 'apple_receipt/receipt_parser'
require 'apple_receipt/validator'

module AppleReceipt
  # Receipt represents an Apple receipt.
  class Receipt
    def initialize(raw_receipt)
      receipt_decoded = Base64.decode64(raw_receipt)
      @version,
        @signature,
        @certificate,
        @data = ReceiptParser.parse(receipt_decoded)
    end

    def purchase_info
      @purchase_info ||= NextStepParser.parse(data)
    end

    def valid?
      Validator.new(self).valid?
    end

    attr_reader :version, :signature, :certificate, :data
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
apple_receipt-0.2.2 lib/apple_receipt/receipt.rb
apple_receipt-0.2.1 lib/apple_receipt/receipt.rb
apple_receipt-0.2.0 lib/apple_receipt/receipt.rb