Permalink
Browse files

Add a method to verify Receipt data from a string.

  • Loading branch information...
1 parent 9f340df commit 7d1f17456f5d5abe83d72613ec8bf29940219f6d @Manfred Manfred committed Sep 18, 2012
Showing with 12 additions and 0 deletions.
  1. +1 −0 README.md
  2. +5 −0 lib/oja.rb
  3. +6 −0 spec/oja_spec.rb
View
@@ -13,6 +13,7 @@ iOS and Mac application receive Receipts when handling purchases from the App St
response = Oja.verify(:data => data)
if response.active?
# Whatever you need to do
+ p response.receipt_data
elsif response.inactive?
# The receipt probably expired
else
View
@@ -3,6 +3,11 @@
require 'oja/response'
module Oja
+ def self.verify(data)
+ receipt = Oja::Receipt.new(:data => data)
+ receipt.verify
+ end
+
def self.verify_filename(receipt_filename)
receipt = Oja::Receipt.new(:filename => receipt_filename)
receipt.verify
View
@@ -2,6 +2,12 @@
require 'oja/mock'
describe Oja do
+ it "verifies receipt data" do
+ response = Oja.verify(receipt_data('receipt'))
+ # The default for the mock response is success
+ response.should.be.active
+ end
+
it "verifies an active receipt from disk" do
response = Oja.verify_filename(receipt_filename('receipt'))
# The default for the mock response is success

0 comments on commit 7d1f174

Please sign in to comment.