Class: CandyCheck::AppStore::Verifier

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

Overview

Verifies receipts against the verification servers. The call return either an Receipt or a VerificationFailure

Constant Summary collapse

PRODUCTION_ENDPOINT =

HTTPS endpoint for production receipts

"https://buy.itunes.apple.com/verifyReceipt".freeze
SANDBOX_ENDPOINT =

HTTPS endpoint for sandbox receipts

"https://sandbox.itunes.apple.com/verifyReceipt".freeze
REDIRECT_TO_SANDBOX_CODE =

Status code from production endpoint when receiving a sandbox receipt which occurs during the app’s review process

21_007
REDIRECT_TO_PRODUCTION_CODE =

Status code from the sandbox endpoint when receiving a production receipt

21_008

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:



23
24
25
# File 'lib/candy_check/app_store/verifier.rb', line 23

def initialize(config)
  @config = config
end

Instance Attribute Details

#configConfig (readonly)

Returns the current configuration.

Returns:

  • (Config)

    the current configuration



18
19
20
# File 'lib/candy_check/app_store/verifier.rb', line 18

def config
  @config
end

Instance Method Details

#verify(receipt_data, secret = nil) ⇒ Receipt, VerificationFailure

Calls a verification for the given input

Parameters:

  • receipt_data (String)

    the raw data to be verified

  • secret (String) (defaults to: nil)

    the optional shared secret

Returns:



32
33
34
# File 'lib/candy_check/app_store/verifier.rb', line 32

def verify(receipt_data, secret = nil)
  fetch_receipt_information(Verification, [receipt_data, secret])
end

#verify_subscription(receipt_data, secret = nil, product_ids = nil) ⇒ ReceiptCollection, Verification

Calls a subscription verification for the given input

Parameters:

  • receipt_data (String)

    the raw data to be verified

  • secret (String) (defaults to: nil)

    optional: shared secret

  • product_ids (Array<String>) (defaults to: nil)

    optional: products to filter

Returns:



42
43
44
45
# File 'lib/candy_check/app_store/verifier.rb', line 42

def verify_subscription(receipt_data, secret = nil, product_ids = nil)
  args = [receipt_data, secret, product_ids]
  fetch_receipt_information(SubscriptionVerification, args)
end