Sha256: c66129561b97f0edf6b7ddb36a774e31530743fcd9a682712145b860d812c5c6
Contents?: true
Size: 1.02 KB
Versions: 1
Compression:
Stored size: 1.02 KB
Contents
require 'excon' require 'json' module Venice ITUNES_PRODUCTION_RECEIPT_VERIFICATION_ENDPOINT = "https://buy.itunes.apple.com/verifyReceipt" ITUNES_DEVELOPMENT_RECEIPT_VERIFICATION_ENDPOINT = "https://sandbox.itunes.apple.com/verifyReceipt" class Client attr_accessor :verification_url def initialize @verification_url = ENV['IAP_VERIFICATION_ENDPOINT'] end def verify!(data) response = Excon.post(@verification_url, :headers => headers, :body => {'receipt-data' => data}.to_json) JSON.parse(response.body) end class << self def development client = self.new client.verification_url = ITUNES_DEVELOPMENT_RECEIPT_VERIFICATION_ENDPOINT client end def production client = self.new client.verification_url = ITUNES_PRODUCTION_RECEIPT_VERIFICATION_ENDPOINT client end end private def headers { 'Accept' => 'application/json', 'Content-Type' => 'application/json' } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
venice-0.0.1 | ./lib/venice/client.rb |