lib/monza/transaction_receipt.rb in monza-0.1.2 vs lib/monza/transaction_receipt.rb in monza-0.1.3
- old
+ new
@@ -1,6 +1,7 @@
require 'time'
+require 'active_support/core_ext/time'
module Monza
class TransactionReceipt
# Receipt Fields Documentation
# https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW1
@@ -21,11 +22,11 @@
attr_reader :expires_date_ms
attr_reader :expires_date_pst
attr_reader :is_trial_period
def initialize(attributes)
- @quantity = attributes['quantity']
+ @quantity = attributes['quantity'].to_i
@product_id = attributes['product_id']
@transaction_id = attributes['transaction_id']
@original_transaction_id = attributes['original_transaction_id']
@purchase_date = DateTime.parse(attributes['purchase_date']) if attributes['purchase_date']
@purchase_date_ms = Time.zone.at(attributes['purchase_date_ms'].to_i / 1000)
@@ -48,22 +49,20 @@
@is_trial_period = attributes['is_trial_period'].to_bool
end
end # end initialize
#
- # Depcrecating - don't use these
+ # Depcrecating - don't use these
# These will only work if the user never cancels and then resubscribes
# The original_transaction_id does not reset after the user resubscribes
#
# def is_renewal?
# !is_first_transaction?
# end
#
# def is_first_transaction?
# @original_transaction_id == @transaction_id
# end
-
-
end # end class
end # end module
#
# Sample JSON Object