Class: CandyCheck::PlayStore::Verifier

Inherits:
Object
  • Object
show all
Defined in:
lib/candy_check/play_store/verifier.rb

Overview

Verifies purchase tokens against the Google API. The call return either an Receipt or a VerificationFailure

Defined Under Namespace

Classes: BootRequiredError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Verifier

Initializes a new verifier for the application which is bound to a configuration

Parameters:



16
17
18
# File 'lib/candy_check/play_store/verifier.rb', line 16

def initialize(config)
  @config = config
end

Instance Attribute Details

#configConfig (readonly)

Returns the current configuration.

Returns:

  • (Config)

    the current configuration



11
12
13
# File 'lib/candy_check/play_store/verifier.rb', line 11

def config
  @config
end

Instance Method Details

#boot!Object

Boot the module



21
22
23
24
25
# File 'lib/candy_check/play_store/verifier.rb', line 21

def boot!
  boot_error('You\'re only allowed to boot the verifier once') if booted?
  @client = Client.new(config)
  @client.boot!
end

#verify(package, product_id, token) ⇒ Receipt, VerificationFailure

Contacts the Google API and requests the product state

Parameters:

  • package (String)

    to query

  • product_id (String)

    to query

  • token (String)

    to use for authentication

Returns:



33
34
35
36
37
# File 'lib/candy_check/play_store/verifier.rb', line 33

def verify(package, product_id, token)
  check_boot!
  verification = Verification.new(@client, package, product_id, token)
  verification.call!
end

#verify_subscription(package, subscription_id, token) ⇒ Receipt, VerificationFailure

Contacts the Google API and requests the product state

Parameters:

  • package (String)

    to query

  • subscription_id (String)

    to query

  • token (String)

    to use for authentication

Returns:



45
46
47
48
49
50
51
# File 'lib/candy_check/play_store/verifier.rb', line 45

def verify_subscription(package, subscription_id, token)
  check_boot!
  v = SubscriptionVerification.new(
    @client, package, subscription_id, token
  )
  v.call!
end