realex 0.3.5 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +33 -0
- data/Rakefile +1 -1
- data/lib/real_ex/recurring.rb +32 -6
- data/lib/real_ex/response.rb +3 -1
- data/realex.gemspec +11 -20
- data/spec/recurring_spec.rb +15 -3
- data/spec/response_spec.rb +1 -0
- metadata +53 -90
data/Gemfile.lock
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
builder (3.0.0)
|
5
|
+
diff-lcs (1.1.3)
|
6
|
+
git (1.2.5)
|
7
|
+
jeweler (1.8.3)
|
8
|
+
bundler (~> 1.0)
|
9
|
+
git (>= 1.2.5)
|
10
|
+
rake
|
11
|
+
rdoc
|
12
|
+
json (1.6.5)
|
13
|
+
nokogiri (1.5.2)
|
14
|
+
rake (0.9.2.2)
|
15
|
+
rdoc (3.12)
|
16
|
+
json (~> 1.4)
|
17
|
+
rspec (2.6.0)
|
18
|
+
rspec-core (~> 2.6.0)
|
19
|
+
rspec-expectations (~> 2.6.0)
|
20
|
+
rspec-mocks (~> 2.6.0)
|
21
|
+
rspec-core (2.6.4)
|
22
|
+
rspec-expectations (2.6.0)
|
23
|
+
diff-lcs (~> 1.1.2)
|
24
|
+
rspec-mocks (2.6.0)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
builder
|
31
|
+
jeweler
|
32
|
+
nokogiri
|
33
|
+
rspec (~> 2.6.0)
|
data/Rakefile
CHANGED
@@ -25,7 +25,7 @@ begin
|
|
25
25
|
gemspec.email = "paul@rslw.com"
|
26
26
|
gemspec.homepage = "http://github.com/paulca/realex"
|
27
27
|
gemspec.authors = ["Paul Campbell"]
|
28
|
-
gemspec.version = "0.
|
28
|
+
gemspec.version = "0.4"
|
29
29
|
gemspec.add_dependency 'nokogiri', '~> 1.4'
|
30
30
|
end
|
31
31
|
rescue LoadError
|
data/lib/real_ex/recurring.rb
CHANGED
@@ -20,7 +20,7 @@ module RealEx
|
|
20
20
|
per.payer(:type => type, :ref => reference) do |payer|
|
21
21
|
payer.title title
|
22
22
|
payer.firstname firstname
|
23
|
-
payer.
|
23
|
+
payer.surname lastname
|
24
24
|
payer.company company
|
25
25
|
payer.address do |add|
|
26
26
|
add.line1 address.line1
|
@@ -85,10 +85,13 @@ module RealEx
|
|
85
85
|
per.card do |c|
|
86
86
|
c.ref reference
|
87
87
|
c.payerref payer.reference
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
|
89
|
+
if !self.cancel
|
90
|
+
c.number card.number
|
91
|
+
c.expdate card.expiry_date
|
92
|
+
c.chname card.cardholder_name
|
93
|
+
c.type card.type
|
94
|
+
end
|
92
95
|
end
|
93
96
|
end
|
94
97
|
end
|
@@ -156,11 +159,34 @@ module RealEx
|
|
156
159
|
end
|
157
160
|
|
158
161
|
# timesttimestamp.merchantid.orderid.amount.currency.payerref
|
162
|
+
def hash
|
163
|
+
RealEx::Client.build_hash([RealEx::Client.timestamp, RealEx::Config.merchant_id, order_id, amount, currency, payer.reference])
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
class Refund < Transaction
|
168
|
+
attributes :payer, :reference
|
169
|
+
|
170
|
+
def request_type
|
171
|
+
'payment-out'
|
172
|
+
end
|
173
|
+
|
174
|
+
def to_xml
|
175
|
+
super do |per|
|
176
|
+
per.amount(amount, :currency => currency)
|
177
|
+
per.payerref payer.reference
|
178
|
+
per.paymentmethod reference
|
179
|
+
per.refundhash refund_hash
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
159
183
|
def hash
|
160
184
|
RealEx::Client.build_hash([RealEx::Client.timestamp, RealEx::Config.merchant_id, order_id, amount, currency, payer.reference])
|
161
185
|
end
|
162
186
|
|
187
|
+
def refund_hash
|
188
|
+
Digest::SHA1.hexdigest(RealEx::Config.refund_password)
|
189
|
+
end
|
163
190
|
end
|
164
|
-
|
165
191
|
end
|
166
192
|
end
|
data/lib/real_ex/response.rb
CHANGED
@@ -9,7 +9,8 @@ module RealEx
|
|
9
9
|
|
10
10
|
attributes :timestamp, :result, :message, :orderid, :merchantid, :account,
|
11
11
|
:cvnresult, :avspostcoderesponse, :pasref, :timetaken,
|
12
|
-
:authtimetaken, :batchid, :avsaddressresponse, :cardissuer
|
12
|
+
:authtimetaken, :batchid, :avsaddressresponse, :cardissuer,
|
13
|
+
:authcode
|
13
14
|
|
14
15
|
def self.new_from_xml(xml)
|
15
16
|
parsed_xml = xml.kind_of?(String) ? Nokogiri.XML(xml) : xml
|
@@ -26,6 +27,7 @@ module RealEx
|
|
26
27
|
r.batchid = (parsed_xml).at('batchid').inner_html if (parsed_xml).at('batchid')
|
27
28
|
r.pasref = (parsed_xml).at('pasref').inner_html if (parsed_xml).at('pasref')
|
28
29
|
r.timetaken = (parsed_xml).at('timetaken').inner_html if (parsed_xml).at('timetaken')
|
30
|
+
r.authcode = (parsed_xml).at('authcode').inner_html if (parsed_xml).at('authcode')
|
29
31
|
r.authtimetaken = (parsed_xml).at('authtimetaken').inner_html if (parsed_xml).at('authtimetaken')
|
30
32
|
if cardissuer = (parsed_xml).at('cardissuer')
|
31
33
|
r.cardissuer = CardIssuer.new()
|
data/realex.gemspec
CHANGED
@@ -4,19 +4,20 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.
|
7
|
+
s.name = "realex"
|
8
|
+
s.version = "0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = ["Paul Campbell"]
|
12
|
+
s.date = "2012-03-15"
|
13
|
+
s.description = "A Ruby library to make use of the payments API at http://realexpayments.com"
|
14
|
+
s.email = "paul@rslw.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.md"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
19
|
"Gemfile",
|
20
|
+
"Gemfile.lock",
|
20
21
|
"README.md",
|
21
22
|
"Rakefile",
|
22
23
|
"lib/real_ex/address.rb",
|
@@ -39,20 +40,10 @@ Gem::Specification.new do |s|
|
|
39
40
|
"spec/spec_helper.rb",
|
40
41
|
"spec/transaction_spec.rb"
|
41
42
|
]
|
42
|
-
s.homepage =
|
43
|
-
s.require_paths = [
|
44
|
-
s.rubygems_version =
|
45
|
-
s.summary =
|
46
|
-
s.test_files = [
|
47
|
-
"spec/address_spec.rb",
|
48
|
-
"spec/card_spec.rb",
|
49
|
-
"spec/config_spec.rb",
|
50
|
-
"spec/real_ex_spec.rb",
|
51
|
-
"spec/recurring_spec.rb",
|
52
|
-
"spec/response_spec.rb",
|
53
|
-
"spec/spec_helper.rb",
|
54
|
-
"spec/transaction_spec.rb"
|
55
|
-
]
|
43
|
+
s.homepage = "http://github.com/paulca/realex"
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.rubygems_version = "1.8.15"
|
46
|
+
s.summary = "Ruby interface to http://realexpayments.com"
|
56
47
|
|
57
48
|
if s.respond_to? :specification_version then
|
58
49
|
s.specification_version = 3
|
data/spec/recurring_spec.rb
CHANGED
@@ -5,6 +5,7 @@ describe "RealEx::Recurring" do
|
|
5
5
|
RealEx::Config.merchant_id = 'paul'
|
6
6
|
RealEx::Config.shared_secret = "He's not dead, he's just asleep!"
|
7
7
|
RealEx::Config.account = 'internet'
|
8
|
+
RealEx::Config.refund_password = 'password'
|
8
9
|
|
9
10
|
@card = RealEx::Card.new(
|
10
11
|
:number => '4111111111111111',
|
@@ -25,16 +26,23 @@ describe "RealEx::Recurring" do
|
|
25
26
|
:currency => 'EUR',
|
26
27
|
:autosettle => true
|
27
28
|
)
|
29
|
+
@refund = RealEx::Recurring::Refund.new(
|
30
|
+
:payer => @payer,
|
31
|
+
:amount => 500,
|
32
|
+
:order_id => 1234,
|
33
|
+
:currency => 'EUR',
|
34
|
+
:autosettle => true
|
35
|
+
)
|
28
36
|
RealEx::Client.stub!(:timestamp).and_return('20090326160218')
|
29
37
|
end
|
30
38
|
|
31
39
|
it "should create tasty XML for the payer" do
|
32
|
-
@payer.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<request type=\"payer-new\" timestamp=\"20090326160218\">\n <merchantid>paul</merchantid>\n <orderid></orderid>\n <account>internet</account>\n <payer type=\"Business\" ref=\"boom\">\n <title>Mr.</title>\n <firstname>Paul</firstname>\n <
|
40
|
+
@payer.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<request type=\"payer-new\" timestamp=\"20090326160218\">\n <merchantid>paul</merchantid>\n <orderid></orderid>\n <account>internet</account>\n <payer type=\"Business\" ref=\"boom\">\n <title>Mr.</title>\n <firstname>Paul</firstname>\n <surname>Campbell</surname>\n <company>Contrast</company>\n <address>\n <line1>My house</line1>\n <line1></line1>\n <line3></line3>\n <city>Dublin</city>\n <county>Dublin</county>\n <postcode>Dublin 2</postcode>\n <country country_code=\"IE\">Ireland</country>\n </address>\n <phonenumbers>\n <home>1</home>\n <work>2</work>\n <fax>3</fax>\n <mobile>4</mobile>\n </phonenumbers>\n <email>paul@contrast.ie</email>\n </payer>\n <sha1hash>7e97b1b743c2599b6c1fd0c5515d369d8372df15</sha1hash>\n</request>\n"
|
33
41
|
end
|
34
42
|
|
35
43
|
it "should create tasty XML for the payer update" do
|
36
44
|
@payer.update = true
|
37
|
-
@payer.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<request type=\"payer-edit\" timestamp=\"20090326160218\">\n <merchantid>paul</merchantid>\n <orderid></orderid>\n <account>internet</account>\n <payer type=\"Business\" ref=\"boom\">\n <title>Mr.</title>\n <firstname>Paul</firstname>\n <
|
45
|
+
@payer.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<request type=\"payer-edit\" timestamp=\"20090326160218\">\n <merchantid>paul</merchantid>\n <orderid></orderid>\n <account>internet</account>\n <payer type=\"Business\" ref=\"boom\">\n <title>Mr.</title>\n <firstname>Paul</firstname>\n <surname>Campbell</surname>\n <company>Contrast</company>\n <address>\n <line1>My house</line1>\n <line1></line1>\n <line3></line3>\n <city>Dublin</city>\n <county>Dublin</county>\n <postcode>Dublin 2</postcode>\n <country country_code=\"IE\">Ireland</country>\n </address>\n <phonenumbers>\n <home>1</home>\n <work>2</work>\n <fax>3</fax>\n <mobile>4</mobile>\n </phonenumbers>\n <email>paul@contrast.ie</email>\n </payer>\n <sha1hash>7e97b1b743c2599b6c1fd0c5515d369d8372df15</sha1hash>\n</request>\n"
|
38
46
|
end
|
39
47
|
|
40
48
|
it "should create lovely XML for the card" do
|
@@ -48,12 +56,16 @@ describe "RealEx::Recurring" do
|
|
48
56
|
|
49
57
|
it "should create lovely XML for the card cancel" do
|
50
58
|
@card.cancel = true
|
51
|
-
@card.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<request type=\"card-cancel-card\" timestamp=\"20090326160218\">\n <merchantid>paul</merchantid>\n <orderid></orderid>\n <account>internet</account>\n <card>\n <ref>billabong</ref>\n <payerref>boom</payerref>\n
|
59
|
+
@card.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<request type=\"card-cancel-card\" timestamp=\"20090326160218\">\n <merchantid>paul</merchantid>\n <orderid></orderid>\n <account>internet</account>\n <card>\n <ref>billabong</ref>\n <payerref>boom</payerref>\n </card>\n <sha1hash>d21f7cb5de344456c235d93b5f7c311bb70069ea</sha1hash>\n</request>\n"
|
52
60
|
end
|
53
61
|
|
54
62
|
it "should create tasty XML for the authorization" do
|
55
63
|
@transaction.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<request type=\"receipt-in\" timestamp=\"20090326160218\">\n <merchantid>paul</merchantid>\n <orderid>1234</orderid>\n <account>internet</account>\n <amount currency=\"EUR\">500</amount>\n <payerref>boom</payerref>\n <paymentmethod></paymentmethod>\n <sha1hash>ec3afd1714b4473210c2b1eda0c6675bd13c411b</sha1hash>\n</request>\n"
|
56
64
|
end
|
65
|
+
|
66
|
+
it "should create tasty XML for the refund" do
|
67
|
+
@refund.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<request type=\"payment-out\" timestamp=\"20090326160218\">\n <merchantid>paul</merchantid>\n <orderid>1234</orderid>\n <account>internet</account>\n <amount currency=\"EUR\">500</amount>\n <payerref>boom</payerref>\n <paymentmethod></paymentmethod>\n <refundhash>5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8</refundhash>\n <sha1hash>ec3afd1714b4473210c2b1eda0c6675bd13c411b</sha1hash>\n</request>\n"
|
68
|
+
end
|
57
69
|
end
|
58
70
|
|
59
71
|
describe "RealEx::Recurring without a full address" do
|
data/spec/response_spec.rb
CHANGED
@@ -62,6 +62,7 @@ describe "RealEx::Response" do
|
|
62
62
|
@response.message.should == '[ test system ] Authorised 171616'
|
63
63
|
@response.pasref.should == '12380877763476'
|
64
64
|
@response.timetaken.should == '1'
|
65
|
+
@response.authcode.should== "171616"
|
65
66
|
@response.authtimetaken.should == '0'
|
66
67
|
@response.cardissuer.country.should == 'IRELAND'
|
67
68
|
@response.cardissuer.countrycode.should == 'IE'
|
metadata
CHANGED
@@ -1,89 +1,69 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: realex
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.4'
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 5
|
10
|
-
version: 0.3.5
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Paul Campbell
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2012-03-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: nokogiri
|
16
|
+
requirement: &70166167360980 !ruby/object:Gem::Requirement
|
22
17
|
none: false
|
23
|
-
requirements:
|
24
|
-
- -
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
|
27
|
-
segments:
|
28
|
-
- 0
|
29
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
30
22
|
type: :runtime
|
31
|
-
requirement: *id001
|
32
23
|
prerelease: false
|
33
|
-
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
|
24
|
+
version_requirements: *70166167360980
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: builder
|
27
|
+
requirement: &70166167360460 !ruby/object:Gem::Requirement
|
36
28
|
none: false
|
37
|
-
requirements:
|
38
|
-
- -
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
|
41
|
-
segments:
|
42
|
-
- 0
|
43
|
-
version: "0"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
44
33
|
type: :runtime
|
45
|
-
requirement: *id002
|
46
34
|
prerelease: false
|
47
|
-
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
|
35
|
+
version_requirements: *70166167360460
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: jeweler
|
38
|
+
requirement: &70166167359960 !ruby/object:Gem::Requirement
|
50
39
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
55
|
-
segments:
|
56
|
-
- 0
|
57
|
-
version: "0"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
58
44
|
type: :development
|
59
|
-
requirement: *id003
|
60
45
|
prerelease: false
|
61
|
-
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
|
46
|
+
version_requirements: *70166167359960
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: nokogiri
|
49
|
+
requirement: &70166167359440 !ruby/object:Gem::Requirement
|
64
50
|
none: false
|
65
|
-
requirements:
|
51
|
+
requirements:
|
66
52
|
- - ~>
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
|
69
|
-
segments:
|
70
|
-
- 1
|
71
|
-
- 4
|
72
|
-
version: "1.4"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.4'
|
73
55
|
type: :runtime
|
74
|
-
requirement: *id004
|
75
56
|
prerelease: false
|
76
|
-
|
57
|
+
version_requirements: *70166167359440
|
77
58
|
description: A Ruby library to make use of the payments API at http://realexpayments.com
|
78
59
|
email: paul@rslw.com
|
79
60
|
executables: []
|
80
|
-
|
81
61
|
extensions: []
|
82
|
-
|
83
|
-
extra_rdoc_files:
|
62
|
+
extra_rdoc_files:
|
84
63
|
- README.md
|
85
|
-
files:
|
64
|
+
files:
|
86
65
|
- Gemfile
|
66
|
+
- Gemfile.lock
|
87
67
|
- README.md
|
88
68
|
- Rakefile
|
89
69
|
- lib/real_ex/address.rb
|
@@ -107,43 +87,26 @@ files:
|
|
107
87
|
- spec/transaction_spec.rb
|
108
88
|
homepage: http://github.com/paulca/realex
|
109
89
|
licenses: []
|
110
|
-
|
111
90
|
post_install_message:
|
112
91
|
rdoc_options: []
|
113
|
-
|
114
|
-
require_paths:
|
92
|
+
require_paths:
|
115
93
|
- lib
|
116
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
95
|
none: false
|
118
|
-
requirements:
|
119
|
-
- -
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
|
122
|
-
|
123
|
-
- 0
|
124
|
-
version: "0"
|
125
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
101
|
none: false
|
127
|
-
requirements:
|
128
|
-
- -
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
|
131
|
-
segments:
|
132
|
-
- 0
|
133
|
-
version: "0"
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
134
106
|
requirements: []
|
135
|
-
|
136
107
|
rubyforge_project:
|
137
|
-
rubygems_version: 1.8.
|
108
|
+
rubygems_version: 1.8.15
|
138
109
|
signing_key:
|
139
110
|
specification_version: 3
|
140
111
|
summary: Ruby interface to http://realexpayments.com
|
141
|
-
test_files:
|
142
|
-
- spec/address_spec.rb
|
143
|
-
- spec/card_spec.rb
|
144
|
-
- spec/config_spec.rb
|
145
|
-
- spec/real_ex_spec.rb
|
146
|
-
- spec/recurring_spec.rb
|
147
|
-
- spec/response_spec.rb
|
148
|
-
- spec/spec_helper.rb
|
149
|
-
- spec/transaction_spec.rb
|
112
|
+
test_files: []
|