Class: Kakeibo::Client::Iap
Constant Summary collapse
- PRODUCTION_ENDPOINT =
"https://buy.itunes.apple.com/verifyReceipt"
- SANDBOX_ENDPOINT =
"https://sandbox.itunes.apple.com/verifyReceipt"
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #fetch(base64_encoded_data, option = {}) ⇒ Object
- #get_receipt ⇒ Object
-
#initialize ⇒ Iap
constructor
A new instance of Iap.
Constructor Details
#initialize ⇒ Iap
Returns a new instance of Iap.
15 16 17 |
# File 'lib/kakeibo/client/iap.rb', line 15 def initialize @response = nil end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
13 14 15 |
# File 'lib/kakeibo/client/iap.rb', line 13 def response @response end |
Instance Method Details
#fetch(base64_encoded_data, option = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/kakeibo/client/iap.rb', line 19 def fetch(base64_encoded_data, option={}) endpoint = PRODUCTION_ENDPOINT if option[:environment] == :sandbox endpoint = SANDBOX_ENDPOINT end parameters = { 'receipt-data' => base64_encoded_data } parameters['password'] = option[:shared_secret] unless option[:shared_secret].nil? uri = URI(endpoint) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER request = Net::HTTP::Post.new(uri.request_uri) request['Accept'] = 'application/json' request['Content-Type'] = 'application/json' request.body = parameters.to_json @response = http.request(request) @response.value @response end |
#get_receipt ⇒ Object
44 45 46 |
# File 'lib/kakeibo/client/iap.rb', line 44 def get_receipt Kakeibo::Client::Receipt::Iap.new(response.body) end |