Class: CandyCheck::PlayStore::Verifier
- Inherits:
-
Object
- Object
- CandyCheck::PlayStore::Verifier
- 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
-
#config ⇒ Config
readonly
The current configuration.
Instance Method Summary collapse
-
#boot! ⇒ Object
Boot the module.
-
#initialize(config) ⇒ Verifier
constructor
Initializes a new verifier for the application which is bound to a configuration.
-
#verify(package, product_id, token) ⇒ Receipt, VerificationFailure
Contacts the Google API and requests the product state.
-
#verify_subscription(package, subscription_id, token) ⇒ Receipt, VerificationFailure
Contacts the Google API and requests the product state.
Constructor Details
#initialize(config) ⇒ Verifier
Initializes a new verifier for the application which is bound to a configuration
16 17 18 |
# File 'lib/candy_check/play_store/verifier.rb', line 16 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Config (readonly)
Returns 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
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
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 |