Class: Vendor::Receipt
- Inherits:
-
Object
- Object
- Vendor::Receipt
- Defined in:
- lib/project/receipt.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#receipt_data ⇒ Object
readonly
Returns the value of attribute receipt_data.
Instance Method Summary collapse
- #check_receipt(receipt_data) ⇒ Object
-
#initialize(receipt_data, params, &block) ⇒ Receipt
constructor
A new instance of Receipt.
Constructor Details
#initialize(receipt_data, params, &block) ⇒ Receipt
Returns a new instance of Receipt.
6 7 8 9 10 11 12 |
# File 'lib/project/receipt.rb', line 6 def initialize(receipt_data, params, &block) @receipt_data = receipt_data @params = params @block = block check_receipt(receipt_data) end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/project/receipt.rb', line 4 def block @block end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
4 5 6 |
# File 'lib/project/receipt.rb', line 4 def params @params end |
#receipt_data ⇒ Object (readonly)
Returns the value of attribute receipt_data.
4 5 6 |
# File 'lib/project/receipt.rb', line 4 def receipt_data @receipt_data end |
Instance Method Details
#check_receipt(receipt_data) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/project/receipt.rb', line 14 def check_receipt(receipt_data) password = @params.secret != "no_secret" ? @params.secret : nil CargoBay.sharedManager.verifyTransactionReceipt(receipt_data, password:password, success:lambda { |receipt| NSUserDefaults["#{@params.id}.receipt"] = receipt @block.call({success: true, object: receipt}.to_object) unless @block.blank? }, failure: lambda { |error| @block.call({success: false, error: error}.to_object) unless @block.blank? }) end |