VRFS-3800 save ios receipt json
This commit is contained in:
parent
dc13534bd6
commit
48873f3485
|
|
@ -269,6 +269,7 @@ require "jam_ruby/models/jam_track_session"
|
|||
require "jam_ruby/models/jamblaster"
|
||||
require "jam_ruby/models/jamblaster_user"
|
||||
require "jam_ruby/models/jamblaster_pairing_request"
|
||||
require "jam_ruby/models/sale_receipt_ios"
|
||||
|
||||
include Jampb
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ module JamRuby
|
|||
# if it can't validate the receipt, or communicate with Apple at all, etc
|
||||
#
|
||||
# So, if this raises exceptions, you can handle them in the stubbed out begin/rescue in ApiJamTracksController#ios_order_placed
|
||||
def self.validateIOSReceipt(receipt, price_data)
|
||||
def self.validateIOSReceipt(receipt, price_data, user, sale)
|
||||
# these are all 'in cents' (as painfully named to be very clear), and all expected to be integers
|
||||
price = price_data['product_price'].to_f * 100.0
|
||||
|
||||
|
|
@ -100,6 +100,12 @@ module JamRuby
|
|||
21008 => 'This receipt is from the production environment, but it was sent to the test environment for verification. Send it to the production environment instead.'
|
||||
}
|
||||
raise err_msgs[json_resp['status']]
|
||||
else
|
||||
receiptJson = SaleReceiptIOS.new
|
||||
receiptJson.user = user
|
||||
receiptJson.sale = sale
|
||||
receiptJson.data_blob = json_resp
|
||||
receiptJson.save!
|
||||
end
|
||||
price_info
|
||||
end
|
||||
|
|
@ -127,7 +133,7 @@ module JamRuby
|
|||
sale.recurly_currency = 'USD'
|
||||
sale.save!
|
||||
else
|
||||
price_info = validateIOSReceipt(receipt, price_data)
|
||||
price_info = validateIOSReceipt(receipt, price_data, current_user, sale)
|
||||
|
||||
SaleLineItem.create_from_jam_track(current_user, sale, jam_track, using_free_credit)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue