amazon_flex_pay 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.rdoc +55 -23
- data/Rakefile +1 -0
- data/lib/amazon_flex_pay.rb +0 -1
- data/lib/amazon_flex_pay/api/base_request.rb +3 -3
- data/lib/amazon_flex_pay/pipelines/base.rb +1 -1
- data/lib/amazon_flex_pay/version.rb +3 -0
- data/test/amazon_flex_pay/api_test.rb +4 -4
- data/test/test_helper.rb +8 -8
- metadata +80 -34
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 68253a01c923bf46f09496fdee4ace08ea2dd9ed
|
4
|
+
data.tar.gz: 6b40beb54028b808d4f41b36e0a7ac3e4e005dbb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7a7aaf429c63410b93674f2ae06635d46bbe0e551993f8e818714683a7b9d5a33e3e2570f330bbba30cc8f362359ee6942a16cfdefcd24934f16d83c56214c08
|
7
|
+
data.tar.gz: be5f27f8a729e0f68c494eafa105c7a2af8a4df3db4ce6fcbe462b3f6a862a53b2b9ba133a48dee74724e79beef1421cbec104c3f6cca73a5cc35d75bd293d5e
|
data/README.rdoc
CHANGED
@@ -2,40 +2,72 @@
|
|
2
2
|
|
3
3
|
Library for Amazon's Flexible Payment Service.
|
4
4
|
|
5
|
-
==
|
5
|
+
== INITIALIZE
|
6
6
|
|
7
|
-
|
7
|
+
Initialize the gem, probably in config/initializers/amazon_flex_pay.rb (for Rails):
|
8
8
|
|
9
9
|
AmazonFlexPay.access_key = 'your access key'
|
10
10
|
AmazonFlexPay.secret_key = 'your secret key'
|
11
|
-
AmazonFlexPay.go_live!
|
11
|
+
AmazonFlexPay.go_live! if Rails.env.production?
|
12
12
|
|
13
|
-
==
|
13
|
+
== CALL
|
14
14
|
|
15
|
-
|
15
|
+
=== AmazonFlexPay::Pipelines
|
16
16
|
|
17
|
-
|
17
|
+
Start here. You'll need tokens for API calls. These are generated by users via
|
18
|
+
parameterized pipelines.
|
18
19
|
|
19
|
-
|
20
|
-
redirect_to pipeline.url('http://example.com/return')
|
20
|
+
==== Example
|
21
21
|
|
22
|
-
|
22
|
+
Construct a single-use pipeline for the user. This is where the user will agree
|
23
|
+
to pay a certain amount to a specific recipient (maybe you?).
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
# notify yourself about error.code and error.message
|
31
|
-
end
|
32
|
-
end
|
33
|
-
redirect_to product_path
|
25
|
+
redirect_to AmazonFlexPay.single_use_pipeline(
|
26
|
+
'mypipeline3292',
|
27
|
+
'http://example.com/return',
|
28
|
+
:recipient_token => 'RTOKEN',
|
29
|
+
:transaction_amount => '12.99'
|
30
|
+
)
|
34
31
|
|
35
|
-
|
32
|
+
=== AmazonFlexPay::API
|
36
33
|
|
37
|
-
|
34
|
+
With tokens, you can make API calls. Note that results are asynchronous via IPNs.
|
35
|
+
Payment and Refund examples are below. You can see all available API methods
|
36
|
+
here[https://github.com/kickstarter/amazon_flex_pay/blob/master/lib/amazon_flex_pay/api.rb].
|
38
37
|
|
39
|
-
|
38
|
+
==== Payment Example
|
40
39
|
|
41
|
-
|
40
|
+
Once you have a sender token, you can attempt to collect.
|
41
|
+
|
42
|
+
begin
|
43
|
+
response = AmazonFlexPay.pay('12.99', 'USD', 'senderToken123')
|
44
|
+
flash[:notice] = "Thanks! Your payment is processing."
|
45
|
+
rescue AmazonFlexPay::API::Error => e
|
46
|
+
flash[:error] = "Sorry, something went wrong."
|
47
|
+
e.errors.each do |error|
|
48
|
+
# notify yourself about error.code and error.message
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
redirect_to product_path
|
53
|
+
|
54
|
+
==== Refund Example
|
55
|
+
|
56
|
+
If you would like to give your last order a $10 refund, you can call the refund
|
57
|
+
method like this:
|
58
|
+
|
59
|
+
order = Order.last
|
60
|
+
|
61
|
+
AmazonFlexPay.refund(
|
62
|
+
order.transaction_id,
|
63
|
+
order.id,
|
64
|
+
caller_description: 'Friends and family discount.',
|
65
|
+
refund_amount: { value: 10, currency_code: 'USD' },
|
66
|
+
)
|
67
|
+
|
68
|
+
Note: In this example, we are using the order id as the caller reference. You
|
69
|
+
can pass any reference that you like. Also, the 'caller_description' and
|
70
|
+
'refund_amount' options are not required. The default refund amount is the
|
71
|
+
original transaction amount.
|
72
|
+
|
73
|
+
Copyright (c) 2013 Kickstarter, released under the MIT license.
|
data/Rakefile
CHANGED
@@ -17,6 +17,7 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
17
17
|
rdoc.rdoc_dir = 'rdoc'
|
18
18
|
rdoc.title = 'AmazonFlexPay'
|
19
19
|
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
+
rdoc.main = 'README.rdoc'
|
20
21
|
rdoc.rdoc_files.include('README.rdoc')
|
21
22
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
23
|
end
|
data/lib/amazon_flex_pay.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module AmazonFlexPay::API #:nodoc:
|
2
|
-
class BaseRequest < AmazonFlexPay::Model
|
2
|
+
class BaseRequest < AmazonFlexPay::Model #:nodoc:
|
3
3
|
def to_url
|
4
4
|
AmazonFlexPay.api_endpoint + '?' + self.to_param
|
5
5
|
end
|
@@ -27,7 +27,7 @@ module AmazonFlexPay::API #:nodoc:
|
|
27
27
|
self.class.to_s.split('::').last
|
28
28
|
end
|
29
29
|
|
30
|
-
class BaseResponse < AmazonFlexPay::Model
|
30
|
+
class BaseResponse < AmazonFlexPay::Model #:nodoc:
|
31
31
|
attribute :request
|
32
32
|
attribute :request_id
|
33
33
|
|
@@ -45,7 +45,7 @@ module AmazonFlexPay::API #:nodoc:
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
class ErrorResponse < AmazonFlexPay::Model
|
48
|
+
class ErrorResponse < AmazonFlexPay::Model #:nodoc:
|
49
49
|
attribute :request_id
|
50
50
|
|
51
51
|
def self.from_xml(xml)
|
@@ -376,12 +376,12 @@ class AmazonFlexPay::APITest < AmazonFlexPay::Test
|
|
376
376
|
|
377
377
|
should "catch and parse errors" do
|
378
378
|
net_http_res = stub(:code => 400)
|
379
|
-
|
379
|
+
request = TestRequest.new(:foo => 'bar')
|
380
|
+
http_response = RestClient::Response.create(error_response, net_http_res, nil, request)
|
380
381
|
RestClient.expects(:get).raises(RestClient::BadRequest.new(http_response))
|
381
382
|
|
382
383
|
error = nil
|
383
384
|
begin
|
384
|
-
request = TestRequest.new(:foo => 'bar')
|
385
385
|
AmazonFlexPay.send(:submit, request)
|
386
386
|
rescue AmazonFlexPay::API::InvalidParams => e
|
387
387
|
error = e
|
@@ -397,11 +397,11 @@ class AmazonFlexPay::APITest < AmazonFlexPay::Test
|
|
397
397
|
|
398
398
|
ActiveSupport::Notifications.subscribed(callback, "amazon_flex_pay.api") do
|
399
399
|
net_http_res = stub(:code => 400)
|
400
|
-
|
400
|
+
request = TestRequest.new(:foo => 'bar')
|
401
|
+
http_response = RestClient::Response.create(error_response, net_http_res, nil, request)
|
401
402
|
RestClient.expects(:get).raises(RestClient::BadRequest.new(http_response))
|
402
403
|
|
403
404
|
begin
|
404
|
-
request = TestRequest.new(:foo => 'bar')
|
405
405
|
AmazonFlexPay.send(:submit, request)
|
406
406
|
rescue AmazonFlexPay::API::Error
|
407
407
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
# load the support libraries
|
2
|
-
require 'test/unit'
|
3
2
|
require 'rubygems'
|
4
|
-
|
5
|
-
require '
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'minitest/spec'
|
5
|
+
require 'minitest/pride'
|
6
|
+
require 'mocha/setup'
|
7
|
+
require 'shoulda'
|
6
8
|
|
7
9
|
# load the gem
|
8
10
|
require_relative '../lib/amazon_flex_pay'
|
9
11
|
|
10
12
|
require_relative 'response_samples'
|
11
13
|
|
12
|
-
class AmazonFlexPay::Test <
|
13
|
-
def
|
14
|
-
|
15
|
-
def self.should(name, &block) # very simple syntax
|
16
|
-
define_method("test_should_#{name.gsub(/[ -]/, '_')}", &block)
|
14
|
+
class AmazonFlexPay::Test < MiniTest::Unit::TestCase
|
15
|
+
def assert_nothing_raised(*)
|
16
|
+
yield
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
metadata
CHANGED
@@ -1,78 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amazon_flex_pay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.11.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Lance Ivy
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-03-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rest-client
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
19
|
+
version: 1.8.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
26
|
+
version: 1.8.0
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: multi_xml
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: 0.5.2
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: 0.5.2
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: activesupport
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 3.0.14
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 3.0.14
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: mocha
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - ">="
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 3.2.5
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 3.2.5
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: shoulda
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
76
123
|
- !ruby/object:Gem::Version
|
77
124
|
version: '0'
|
78
125
|
description: A straight-forward REST API for Amazon's Flexible Payments Services.
|
@@ -81,6 +128,11 @@ executables: []
|
|
81
128
|
extensions: []
|
82
129
|
extra_rdoc_files: []
|
83
130
|
files:
|
131
|
+
- LICENSE
|
132
|
+
- README.rdoc
|
133
|
+
- Rakefile
|
134
|
+
- lib/amazon_flex_pay.rb
|
135
|
+
- lib/amazon_flex_pay/api.rb
|
84
136
|
- lib/amazon_flex_pay/api/base_request.rb
|
85
137
|
- lib/amazon_flex_pay/api/cancel.rb
|
86
138
|
- lib/amazon_flex_pay/api/cancel_token.rb
|
@@ -98,22 +150,18 @@ files:
|
|
98
150
|
- lib/amazon_flex_pay/api/reserve.rb
|
99
151
|
- lib/amazon_flex_pay/api/settle.rb
|
100
152
|
- lib/amazon_flex_pay/api/verify_signature.rb
|
101
|
-
- lib/amazon_flex_pay/api.rb
|
102
153
|
- lib/amazon_flex_pay/data_types.rb
|
103
154
|
- lib/amazon_flex_pay/enumerations.rb
|
104
155
|
- lib/amazon_flex_pay/model.rb
|
156
|
+
- lib/amazon_flex_pay/pipelines.rb
|
105
157
|
- lib/amazon_flex_pay/pipelines/base.rb
|
106
158
|
- lib/amazon_flex_pay/pipelines/edit_token.rb
|
107
159
|
- lib/amazon_flex_pay/pipelines/multi_use.rb
|
108
160
|
- lib/amazon_flex_pay/pipelines/recipient.rb
|
109
161
|
- lib/amazon_flex_pay/pipelines/single_use.rb
|
110
|
-
- lib/amazon_flex_pay/pipelines.rb
|
111
162
|
- lib/amazon_flex_pay/signature.rb
|
112
163
|
- lib/amazon_flex_pay/util.rb
|
113
|
-
- lib/amazon_flex_pay.rb
|
114
|
-
- LICENSE
|
115
|
-
- README.rdoc
|
116
|
-
- Rakefile
|
164
|
+
- lib/amazon_flex_pay/version.rb
|
117
165
|
- test/amazon_flex_pay/api/base_request_test.rb
|
118
166
|
- test/amazon_flex_pay/api_test.rb
|
119
167
|
- test/amazon_flex_pay/data_types_test.rb
|
@@ -125,27 +173,26 @@ files:
|
|
125
173
|
- test/test_helper.rb
|
126
174
|
homepage: http://github.com/kickstarter/amazon_flex_pay
|
127
175
|
licenses: []
|
176
|
+
metadata: {}
|
128
177
|
post_install_message:
|
129
178
|
rdoc_options: []
|
130
179
|
require_paths:
|
131
180
|
- lib
|
132
181
|
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
-
none: false
|
134
182
|
requirements:
|
135
|
-
- -
|
183
|
+
- - ">="
|
136
184
|
- !ruby/object:Gem::Version
|
137
185
|
version: '0'
|
138
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
-
none: false
|
140
187
|
requirements:
|
141
|
-
- -
|
188
|
+
- - ">="
|
142
189
|
- !ruby/object:Gem::Version
|
143
190
|
version: '0'
|
144
191
|
requirements: []
|
145
192
|
rubyforge_project:
|
146
|
-
rubygems_version:
|
193
|
+
rubygems_version: 2.2.2
|
147
194
|
signing_key:
|
148
|
-
specification_version:
|
195
|
+
specification_version: 4
|
149
196
|
summary: API layer for Amazon FPS
|
150
197
|
test_files:
|
151
198
|
- test/amazon_flex_pay/api/base_request_test.rb
|
@@ -157,4 +204,3 @@ test_files:
|
|
157
204
|
- test/amazon_flex_pay/util_test.rb
|
158
205
|
- test/response_samples.rb
|
159
206
|
- test/test_helper.rb
|
160
|
-
has_rdoc:
|