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 a SubscriptionPurchases::SubscriptionPurchase or a VerificationFailure

Instance Method Summary collapse

Constructor Details

#initialize(authorization:) ⇒ Verifier

Initializes a new verifier which is bound to an authorization

Parameters:

  • authorization (Google::Auth::ServiceAccountCredentials)

    to use against the PlayStore API


8
9
10
# File 'lib/candy_check/play_store/verifier.rb', line 8

def initialize(authorization:)
  @authorization = authorization
end

Instance Method Details

#verify_product_purchase(package_name:, product_id:, token:) ⇒ ProductPurchases::ProductPurchase, VerificationFailure

Contacts the Google API and requests the product state

Parameters:

  • package_name (String)

    to query

  • product_id (String)

    to query

  • token (String)

    to use for authentication

Returns:


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

def verify_product_purchase(package_name:, product_id:, token:)
  verifier = CandyCheck::PlayStore::ProductPurchases::ProductVerification.new(
    package_name: package_name,
    product_id: product_id,
    token: token,
    authorization: @authorization,
  )
  verifier.call!
end

#verify_subscription_purchase(package_name:, subscription_id:, token:) ⇒ SubscriptionPurchases::SubscriptionPurchase, VerificationFailure

Contacts the Google API and requests the product state

Parameters:

  • package_name (String)

    to query

  • subscription_id (String)

    to query

  • token (String)

    to use for authentication

Returns:


34
35
36
37
38
39
40
41
42
# File 'lib/candy_check/play_store/verifier.rb', line 34

def verify_subscription_purchase(package_name:, subscription_id:, token:)
  verifier = CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionVerification.new(
    package_name: package_name,
    subscription_id: subscription_id,
    token: token,
    authorization: @authorization,
  )
  verifier.call!
end