sage_pay 0.2.12 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +15 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +39 -0
- data/lib/sage_pay.rb +1 -1
- data/lib/sage_pay/server/address.rb +9 -0
- data/sage_pay.gemspec +7 -4
- data/spec/integration/sage_pay/server_spec.rb +45 -0
- data/spec/sage_pay/server/address_spec.rb +14 -2
- data/spec/sage_pay_spec.rb +2 -2
- metadata +39 -10
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.2.13
|
4
|
+
|
5
|
+
* If the country for an address is the US, then the US state is required.
|
6
|
+
Otherwise, it should not be supplied since it only make sense in the context
|
7
|
+
of US states.
|
8
|
+
|
9
|
+
* Use Bundler to track development dependencies.
|
10
|
+
|
11
|
+
* Record that ActiveSupport is actually a dependency.
|
12
|
+
|
13
|
+
## 0.2.12
|
14
|
+
|
15
|
+
* Somehow didn't make it into the ChangeLog. Some bug fix or other I'd
|
16
|
+
imagine. :)
|
17
|
+
|
3
18
|
## 0.2.11
|
4
19
|
|
5
20
|
* Cancel support for cancelling existing authorised transactions.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
dependencies:
|
3
|
+
rake:
|
4
|
+
group:
|
5
|
+
- :development
|
6
|
+
version: ">= 0"
|
7
|
+
uuid:
|
8
|
+
group:
|
9
|
+
- :default
|
10
|
+
version: ">= 2.3.1"
|
11
|
+
rspec:
|
12
|
+
group:
|
13
|
+
- :development
|
14
|
+
version: ">= 0"
|
15
|
+
activesupport:
|
16
|
+
group:
|
17
|
+
- :default
|
18
|
+
version: ">= 2.3.8"
|
19
|
+
validatable:
|
20
|
+
group:
|
21
|
+
- :default
|
22
|
+
version: ">= 1.6.7"
|
23
|
+
specs:
|
24
|
+
- rake:
|
25
|
+
version: 0.8.7
|
26
|
+
- activesupport:
|
27
|
+
version: 2.3.8
|
28
|
+
- macaddr:
|
29
|
+
version: 1.0.0
|
30
|
+
- rspec:
|
31
|
+
version: 1.3.0
|
32
|
+
- uuid:
|
33
|
+
version: 2.3.1
|
34
|
+
- validatable:
|
35
|
+
version: 1.6.7
|
36
|
+
hash: 64c077bdede3436c2ce404a8f1824f50cf7a1f7c
|
37
|
+
sources:
|
38
|
+
- Rubygems:
|
39
|
+
uri: http://gemcutter.org
|
data/lib/sage_pay.rb
CHANGED
@@ -35,11 +35,20 @@ module SagePay
|
|
35
35
|
validates_inclusion_of :state, :in => us_states, :allow_blank => true, :message => "is not a US state"
|
36
36
|
validates_inclusion_of :country, :in => iso_3166_country_codes, :allow_blank => true, :message => "is not an ISO3166-1 country code"
|
37
37
|
|
38
|
+
# The state's presence is required if the country is the US, and
|
39
|
+
# verboten otherwise.
|
40
|
+
validates_true_for :state, :key => :state_required_in_us, :logic => lambda { in_us? ? state.present? : true }, :message => "is required if the country is US"
|
41
|
+
validates_true_for :state, :key => :verboten_outside_us, :logic => lambda { in_us? ? true : !state.present? }, :message => "is present but the country is not US"
|
42
|
+
|
38
43
|
def initialize(attributes = {})
|
39
44
|
attributes.each do |k, v|
|
40
45
|
send("#{k}=", v)
|
41
46
|
end
|
42
47
|
end
|
48
|
+
|
49
|
+
def in_us?
|
50
|
+
country == "US"
|
51
|
+
end
|
43
52
|
end
|
44
53
|
end
|
45
54
|
end
|
data/sage_pay.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
## If your rubyforge_project name is different, then edit it and comment out
|
8
8
|
## the sub! line in the Rakefile
|
9
9
|
s.name = 'sage_pay'
|
10
|
-
s.version = '0.2.
|
11
|
-
s.date = '2010-
|
10
|
+
s.version = '0.2.13'
|
11
|
+
s.date = '2010-08-15'
|
12
12
|
s.rubyforge_project = 'sage_pay'
|
13
13
|
|
14
14
|
## Make sure your summary is short. The description may be as long
|
@@ -37,8 +37,9 @@ gateway for accepting credit card payments through your web app.
|
|
37
37
|
|
38
38
|
## List your runtime dependencies here. Runtime dependencies are those
|
39
39
|
## that are needed for an end user to actually USE your code.
|
40
|
-
s.add_dependency('
|
41
|
-
s.add_dependency('
|
40
|
+
s.add_dependency('activesupport', [">= 2.3.8"])
|
41
|
+
s.add_dependency('validatable', [">= 1.6.7"])
|
42
|
+
s.add_dependency('uuid', [">= 2.3.0"])
|
42
43
|
|
43
44
|
## List your development dependencies here. Development dependencies are
|
44
45
|
## those that are only needed during development
|
@@ -50,6 +51,8 @@ gateway for accepting credit card payments through your web app.
|
|
50
51
|
# = MANIFEST =
|
51
52
|
s.files = %w[
|
52
53
|
CHANGELOG.md
|
54
|
+
Gemfile
|
55
|
+
Gemfile.lock
|
53
56
|
LICENSE
|
54
57
|
README.md
|
55
58
|
Rakefile
|
@@ -59,6 +59,51 @@ if run_integration_specs?
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
describe ".payment with a US address" do
|
63
|
+
before(:each) do
|
64
|
+
@payment = SagePay::Server.payment(
|
65
|
+
:description => "Demo payment",
|
66
|
+
:amount => 12.34,
|
67
|
+
:currency => "GBP",
|
68
|
+
:billing_address => address_factory(:country => "US", :state => "WY")
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should successfully register the payment with SagePay" do
|
73
|
+
@payment.run!.should_not be_nil
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should be a valid registered payment" do
|
77
|
+
registration = @payment.run!
|
78
|
+
registration.should be_ok
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should have a next URL" do
|
82
|
+
registration = @payment.run!
|
83
|
+
registration.next_url.should_not be_nil
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should allow us to follow the next URL and the response should be successful" do
|
87
|
+
registration = @payment.run!
|
88
|
+
uri = URI.parse(registration.next_url)
|
89
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
90
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
91
|
+
http.use_ssl = true if uri.scheme == "https"
|
92
|
+
http.start { |http|
|
93
|
+
http.request(request)
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should allow us to retrieve signature verification details" do
|
98
|
+
@payment.run!
|
99
|
+
sig_details = @payment.signature_verification_details
|
100
|
+
|
101
|
+
sig_details.should_not be_nil
|
102
|
+
sig_details.security_key.should_not be_nil
|
103
|
+
sig_details.vendor.should_not be_nil
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
62
107
|
describe ".deferred" do
|
63
108
|
before(:each) do
|
64
109
|
@payment = SagePay::Server.deferred(
|
@@ -100,10 +100,22 @@ describe SagePay::Server::Address do
|
|
100
100
|
]
|
101
101
|
end
|
102
102
|
|
103
|
+
it "should require a US state to be present if the country is the US" do
|
104
|
+
address = address_factory(:country => "US", :state => "")
|
105
|
+
address.should_not be_valid
|
106
|
+
address.errors.on(:state).should == "is required if the country is US"
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should require the US state to be absent if the country is not in the US" do
|
110
|
+
address = address_factory(:country => "GB", :state => "WY")
|
111
|
+
address.should_not be_valid
|
112
|
+
address.errors.on(:state).should == "is present but the country is not US"
|
113
|
+
end
|
114
|
+
|
103
115
|
it "should validate the state against a list of US states" do
|
104
|
-
address = address_factory(:state => "WY")
|
116
|
+
address = address_factory(:country => "US", :state => "WY")
|
105
117
|
address.should be_valid
|
106
|
-
address = address_factory(:state => "AA")
|
118
|
+
address = address_factory(:country => "US", :state => "AA")
|
107
119
|
address.should_not be_valid
|
108
120
|
address.errors.on(:state).should == "is not a US state"
|
109
121
|
end
|
data/spec/sage_pay_spec.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sage_pay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 13
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
9
|
+
- 13
|
10
|
+
version: 0.2.13
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Graeme Mathieson
|
@@ -14,49 +15,71 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-08-15 00:00:00 +01:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
22
|
+
name: activesupport
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 19
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 3
|
33
|
+
- 8
|
34
|
+
version: 2.3.8
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: validatable
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 1
|
27
46
|
segments:
|
28
47
|
- 1
|
29
48
|
- 6
|
30
49
|
- 7
|
31
50
|
version: 1.6.7
|
32
51
|
type: :runtime
|
33
|
-
version_requirements: *
|
52
|
+
version_requirements: *id002
|
34
53
|
- !ruby/object:Gem::Dependency
|
35
54
|
name: uuid
|
36
55
|
prerelease: false
|
37
|
-
requirement: &
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
38
58
|
requirements:
|
39
59
|
- - ">="
|
40
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
41
62
|
segments:
|
42
63
|
- 2
|
43
64
|
- 3
|
44
65
|
- 0
|
45
66
|
version: 2.3.0
|
46
67
|
type: :runtime
|
47
|
-
version_requirements: *
|
68
|
+
version_requirements: *id003
|
48
69
|
- !ruby/object:Gem::Dependency
|
49
70
|
name: rspec
|
50
71
|
prerelease: false
|
51
|
-
requirement: &
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
52
74
|
requirements:
|
53
75
|
- - ">="
|
54
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
55
78
|
segments:
|
56
79
|
- 0
|
57
80
|
version: "0"
|
58
81
|
type: :development
|
59
|
-
version_requirements: *
|
82
|
+
version_requirements: *id004
|
60
83
|
description: |
|
61
84
|
This is a Ruby library for integrating with SagePay. SagePay is a payment
|
62
85
|
gateway for accepting credit card payments through your web app.
|
@@ -71,6 +94,8 @@ extra_rdoc_files:
|
|
71
94
|
- LICENSE
|
72
95
|
files:
|
73
96
|
- CHANGELOG.md
|
97
|
+
- Gemfile
|
98
|
+
- Gemfile.lock
|
74
99
|
- LICENSE
|
75
100
|
- README.md
|
76
101
|
- Rakefile
|
@@ -123,23 +148,27 @@ rdoc_options:
|
|
123
148
|
require_paths:
|
124
149
|
- lib
|
125
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
none: false
|
126
152
|
requirements:
|
127
153
|
- - ">="
|
128
154
|
- !ruby/object:Gem::Version
|
155
|
+
hash: 3
|
129
156
|
segments:
|
130
157
|
- 0
|
131
158
|
version: "0"
|
132
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
none: false
|
133
161
|
requirements:
|
134
162
|
- - ">="
|
135
163
|
- !ruby/object:Gem::Version
|
164
|
+
hash: 3
|
136
165
|
segments:
|
137
166
|
- 0
|
138
167
|
version: "0"
|
139
168
|
requirements: []
|
140
169
|
|
141
170
|
rubyforge_project: sage_pay
|
142
|
-
rubygems_version: 1.3.
|
171
|
+
rubygems_version: 1.3.7
|
143
172
|
signing_key:
|
144
173
|
specification_version: 2
|
145
174
|
summary: Ruby implementation of the SagePay payment gateway protocol.
|