./lib/venice/in_app_receipt.rb in venice-0.4.3 vs ./lib/venice/in_app_receipt.rb in venice-0.5.0
- old
+ new
@@ -52,14 +52,15 @@
@transaction_id = attributes['transaction_id']
@web_order_line_item_id = attributes['web_order_line_item_id']
@purchased_at = DateTime.parse(attributes['purchase_date']) if attributes['purchase_date']
@app_item_id = attributes['app_item_id']
@version_external_identifier = attributes['version_external_identifier']
+ @is_trial_period = attributes['is_trial_period'].to_s == 'true'
# expires_date is in ms since the Epoch, Time.at expects seconds
if attributes['expires_date_ms']
- @expires_at = Time.at(attributes['expires_date_ms'].to_i / 1000)
+ @expires_at = Time.at(attributes['expires_date_ms'].to_i / 1000)
elsif attributes['expires_date'] && is_number?(attributes['expires_date'])
@expires_at = Time.at(attributes['expires_date'].to_i / 1000)
end
# cancellation_date is in ms since the Epoch, Time.at expects seconds
@@ -84,21 +85,22 @@
purchase_date: (@purchased_at.httpdate rescue nil),
original_transaction_id: (@original.transaction_id rescue nil),
original_purchase_date: (@original.purchased_at.httpdate rescue nil),
app_item_id: @app_item_id,
version_external_identifier: @version_external_identifier,
+ is_trial_period: @is_trial_period,
expires_at: (@expires_at.httpdate rescue nil),
cancellation_at: (@cancellation_at.httpdate rescue nil)
}
end
alias_method :to_h, :to_hash
def to_json
to_hash.to_json
end
-
+
private
-
+
def is_number?(string)
!!(string && string.to_s =~ /^[0-9]+$/)
end
end
end