Sha256: 2be075649d94fe67fc7de13b4f28a495efdf1372b43ef799f2a0fb22b6ffd851
Contents?: true
Size: 1.33 KB
Versions: 4
Compression:
Stored size: 1.33 KB
Contents
module CandyCheck module PlayStore # Verifies a purchase token against the Google API # The call return either an {Receipt} or an {VerificationFailure} class Verification # @return [String] the package which will be queried attr_reader :package # @return [String] the item id which will be queried attr_reader :product_id # @return [String] the token for authentication attr_reader :token # Initializes a new call to the API # @param client [Client] a shared client instance # @param package [String] # @param product_id [String] # @param token [String] def initialize(client, package, product_id, token) @client = client @package = package @product_id = product_id @token = token end # Performs the verification against the remote server # @return [Receipt] if successful # @return [VerificationFailure] otherwise def call! verify! if valid? Receipt.new(@response) else VerificationFailure.new(@response['error']) end end private def valid? @response && @response['purchaseState'] && @response['consumptionState'] end def verify! @response = @client.verify(package, product_id, token) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems