Class: CandyCheck::AppStore::Verification

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

Overview

Verifies a receipt block against a verification server. The call return either an Receipt or a VerificationFailure

Direct Known Subclasses

SubscriptionVerification

Constant Summary collapse

STATUS_OK =

Constant for successful responses

0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint_url, receipt_data, secret = nil) ⇒ Verification

Builds a fresh verification run

Parameters:

  • endpoint_url (String)

    the verification URL to use

  • receipt_data (String)

    the raw data to be verified

  • secret (String) (defaults to: nil)

    optional: shared secret



20
21
22
23
24
# File 'lib/candy_check/app_store/verification.rb', line 20

def initialize(endpoint_url, receipt_data, secret = nil)
  @endpoint_url = endpoint_url
  @receipt_data = receipt_data
  @secret = secret
end

Instance Attribute Details

#endpoint_urlString (readonly)

Returns the verification URL to use.

Returns:

  • (String)

    the verification URL to use



7
8
9
# File 'lib/candy_check/app_store/verification.rb', line 7

def endpoint_url
  @endpoint_url
end

#receipt_dataString (readonly)

Returns the raw data to be verified.

Returns:

  • (String)

    the raw data to be verified



9
10
11
# File 'lib/candy_check/app_store/verification.rb', line 9

def receipt_data
  @receipt_data
end

#secretString (readonly)

Returns the optional shared secret.

Returns:

  • (String)

    the optional shared secret



11
12
13
# File 'lib/candy_check/app_store/verification.rb', line 11

def secret
  @secret
end

Instance Method Details

#call!Receipt, VerificationFailure

Performs the verification against the remote server

Returns:



29
30
31
32
33
34
35
36
# File 'lib/candy_check/app_store/verification.rb', line 29

def call!
  verify!
  if valid?
    Receipt.new(@response["receipt"])
  else
    VerificationFailure.fetch(@response["status"])
  end
end