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'
SANDBOX_ENDPOINT =

HTTPS endpoint for sandbox receipts

'https://sandbox.itunes.apple.com/verifyReceipt'
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
35
36
37
38
39
# File 'lib/candy_check/app_store/verifier.rb', line 32

def verify(receipt_data, secret = nil)
  default_endpoint, opposite_endpoint = endpoints
  result = call_for(default_endpoint, receipt_data, secret)
  if should_retry?(result)
    return call_for(opposite_endpoint, receipt_data, secret)
  end
  result
end