itunes_receipt_decoder 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/itunes_receipt_decoder/decode/base.rb +1 -1
- data/lib/itunes_receipt_decoder/decode/transaction_receipt.rb +9 -11
- data/lib/itunes_receipt_decoder/decode/unified_receipt.rb +5 -1
- data/lib/itunes_receipt_decoder/version.rb +1 -1
- data/lib/itunes_receipt_decoder.rb +3 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7249d3ca881c622ef2e0ccd6d94be8da200eece2
|
4
|
+
data.tar.gz: ccea5b7c522881e76705920a20a6ab49a396d7ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 812a954786a1bb1dc53677e68a8fe8494b6f8f46765d5ce8404132354680bccffc774bd2fb909e1d76e06e643493da1b4b010eb701b3e680270c91093e86b562
|
7
|
+
data.tar.gz: 0887a6b967bdd98309bc052812bfee0500d3cdcec88725e8cf0f109f3e0e0ff2de186e5624bfc73ce46d68ccedf820d7cc41c4f2d9cc0f2adb767b036db21394
|
@@ -16,9 +16,11 @@ module ItunesReceiptDecoder
|
|
16
16
|
|
17
17
|
def decode
|
18
18
|
@receipt = parse_purchase_info
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
if payload.fetch('environment', 'Production') == 'Production'
|
20
|
+
@environment = :production
|
21
|
+
else
|
22
|
+
@environment = :sandbox
|
23
|
+
end
|
22
24
|
end
|
23
25
|
|
24
26
|
def parse_purchase_info
|
@@ -30,14 +32,8 @@ module ItunesReceiptDecoder
|
|
30
32
|
end
|
31
33
|
|
32
34
|
def purchase_info
|
33
|
-
|
34
|
-
|
35
|
-
rescue KeyError => e
|
36
|
-
raise DecodingError, e.message
|
37
|
-
rescue ArgumentError => e
|
38
|
-
raise DecodingError, e.message
|
39
|
-
else
|
40
|
-
@purchase_info = parse_plist(contents)
|
35
|
+
@purchase_info ||=
|
36
|
+
parse_plist(payload.fetch('purchase-info').unpack('m').first)
|
41
37
|
end
|
42
38
|
|
43
39
|
def payload
|
@@ -49,6 +45,8 @@ module ItunesReceiptDecoder
|
|
49
45
|
hash = CFPropertyList.native_types(plist.value)
|
50
46
|
fail DecodingError, 'hash not found in plist' unless hash.is_a?(Hash)
|
51
47
|
hash
|
48
|
+
rescue CFPlistError => e
|
49
|
+
raise DecodingError, e.message
|
52
50
|
end
|
53
51
|
end
|
54
52
|
end
|
@@ -43,7 +43,11 @@ module ItunesReceiptDecoder
|
|
43
43
|
|
44
44
|
def decode
|
45
45
|
@receipt = parse_app_receipt_fields(payload.value)
|
46
|
-
|
46
|
+
if @receipt.fetch(:environment, 'Production') == 'Production'
|
47
|
+
@environment = :production
|
48
|
+
else
|
49
|
+
@environment = :sandbox
|
50
|
+
end
|
47
51
|
end
|
48
52
|
|
49
53
|
def parse_app_receipt_fields(fields)
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'time'
|
2
|
-
require 'base64'
|
3
2
|
require 'openssl'
|
4
3
|
require 'cfpropertylist'
|
5
4
|
require 'itunes_receipt_decoder/version'
|
@@ -22,12 +21,12 @@ module ItunesReceiptDecoder
|
|
22
21
|
# * +receipt_data+ - the base64 encoded receipt
|
23
22
|
# * +options+ - optional arguments
|
24
23
|
def self.new(receipt_data, options = {})
|
25
|
-
raw_receipt =
|
24
|
+
raw_receipt = receipt_data.unpack('m').first
|
26
25
|
rescue ArgumentError => e
|
27
26
|
raise DecodingError, e.message
|
28
27
|
else
|
29
|
-
if (match = raw_receipt.match(PLIST_REGEX))
|
30
|
-
Decode::TransactionReceipt.new(match
|
28
|
+
if (match = raw_receipt.match(PLIST_REGEX).to_a.first) && match.ascii_only?
|
29
|
+
Decode::TransactionReceipt.new(match, options)
|
31
30
|
else
|
32
31
|
Decode::UnifiedReceipt.new(raw_receipt, options)
|
33
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itunes_receipt_decoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mbaasy.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: CFPropertyList
|