amazon-iap 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +37 -24
- data/lib/amazon/iap/exceptions.rb +8 -7
- data/lib/amazon/iap/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -28,18 +28,25 @@ for more details.
|
|
28
28
|
Initialize a client, passing in the developer secret and (optionally) the host. If a host is not
|
29
29
|
passed, it will use Amazon's production endpoint.
|
30
30
|
|
31
|
-
|
31
|
+
```ruby
|
32
|
+
client = Amazon::Iap::Client.new 'my_developer_secret', 'http://iap-staging.domain.com' # staging server
|
33
|
+
client = Amazon::Iap::Client.new 'my_developer_secret' # production server
|
34
|
+
```
|
32
35
|
|
33
36
|
From there, you can call either `verify` or `renew` on the client and pass in the user id and purchase token:
|
34
37
|
|
35
|
-
|
36
|
-
|
38
|
+
```ruby
|
39
|
+
result = client.verify 'some-user-id', 'some-purchase-token'
|
40
|
+
result = client.renew 'some-user-id', 'some-purchase-token'
|
41
|
+
```
|
37
42
|
|
38
43
|
By default, the `verify` method will automatically try to renew expired tokens, and will recall `verify`
|
39
44
|
against the new token returned. If you do not want this behavior, simply pass in `false` as the third
|
40
45
|
attribute to the `verify` method:
|
41
46
|
|
42
|
-
|
47
|
+
```ruby
|
48
|
+
result = client.verify 'some-user-id', 'some-purchase-token', false
|
49
|
+
```
|
43
50
|
|
44
51
|
## Returned Values
|
45
52
|
|
@@ -47,23 +54,27 @@ An instance of Amazon::Iap::Result is returned from both methods, the attributes
|
|
47
54
|
of the hash keys returned in the JSON object. For convenience, we also add `start_time` and `end_time` attributes
|
48
55
|
which are `Time` representations of the milliseconds returned in `start_date` and `end_date` respectively. E.g.,
|
49
56
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
```ruby
|
58
|
+
result = client.verify 'some-user-id', 'some-purchase-token'
|
59
|
+
|
60
|
+
result.class.name # "Amazon::Iap::Result"
|
61
|
+
result.item_type # "SUBSCRIPTION"
|
62
|
+
result.sku # "some-sku"
|
63
|
+
result.start_date # 1378751554943
|
64
|
+
result.start_time # 2013-09-09 14:32:34 -0400
|
65
|
+
result.end_date # nil
|
66
|
+
result.end_time # nil
|
67
|
+
result.purchase_token # "some-purchase-token"
|
68
|
+
```
|
60
69
|
|
61
70
|
<!-- -->
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
result = client.renew 'some-user-id', 'some-purchase-token'
|
74
|
+
|
75
|
+
result.class.name # "Amazon::Iap::Result"
|
76
|
+
result.purchase_token # "some-new-purchase-token"
|
77
|
+
```
|
67
78
|
|
68
79
|
## Exception Handling
|
69
80
|
|
@@ -72,11 +83,13 @@ a distinct exception. Take a look at the [Amazon::Iap::Result class](lib/amazon
|
|
72
83
|
|
73
84
|
Example exception handling:
|
74
85
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
86
|
+
```ruby
|
87
|
+
begin
|
88
|
+
result = client.verify 'some-user-id', 'some-purchase-token'
|
89
|
+
rescue Amazon::Iap::Exceptions::InternalError => e
|
90
|
+
# enqueue to try again later
|
91
|
+
end
|
92
|
+
```
|
80
93
|
|
81
94
|
## Contributing
|
82
95
|
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module Amazon
|
2
2
|
module Iap
|
3
3
|
module Exceptions
|
4
|
-
class
|
5
|
-
class
|
6
|
-
class
|
7
|
-
class
|
8
|
-
class
|
9
|
-
class
|
10
|
-
class
|
4
|
+
class Exception < Exception; end
|
5
|
+
class InvalidTransaction < Amazon::Iap::Exceptions::Exception; end
|
6
|
+
class InvalidSharedSecret < Amazon::Iap::Exceptions::Exception; end
|
7
|
+
class InvalidUserId < Amazon::Iap::Exceptions::Exception; end
|
8
|
+
class InvalidPurchaseToken < Amazon::Iap::Exceptions::Exception; end
|
9
|
+
class ExpiredCredentials < Amazon::Iap::Exceptions::Exception; end
|
10
|
+
class InternalError < Amazon::Iap::Exceptions::Exception; end
|
11
|
+
class General < Amazon::Iap::Exceptions::Exception; end
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
data/lib/amazon/iap/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon-iap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|