realex 0.3.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.md +6 -0
- data/Rakefile +5 -5
- data/lib/real_ex/client.rb +1 -1
- data/lib/real_ex/config.rb +1 -1
- data/lib/real_ex/recurring.rb +18 -5
- data/lib/real_ex/transaction.rb +5 -3
- data/realex.gemspec +5 -5
- data/spec/recurring_spec.rb +7 -2
- data/spec/spec_helper.rb +2 -2
- metadata +21 -23
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -54,3 +54,9 @@ This is a Ruby library for interfacing with the RealEx API ( http://www.realexpa
|
|
54
54
|
transaction = RealEx::Recurring::Authorization.new(:amount => 500, :payer => payer, :order_id => order_id, :reference => 'paulcampbell')
|
55
55
|
|
56
56
|
transaction.authorize!
|
57
|
+
|
58
|
+
## Cancelling a recurring payment card ##
|
59
|
+
|
60
|
+
recurring_card = RealEx::Recurring::Card.new(:payer => payer, :reference => 'paulcampbell')
|
61
|
+
|
62
|
+
recurring_card.destroy!
|
data/Rakefile
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require '
|
2
|
+
require 'rspec/core/rake_task'
|
3
3
|
|
4
4
|
desc 'Default: run specs.'
|
5
5
|
task :default => :spec
|
6
6
|
|
7
7
|
desc 'Run the specs'
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
9
|
+
spec.rspec_opts = ['--colour --format progress']
|
10
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
11
11
|
end
|
12
12
|
|
13
13
|
PKG_FILES = FileList[
|
@@ -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.3.
|
28
|
+
gemspec.version = "0.3.5"
|
29
29
|
gemspec.add_dependency 'nokogiri', '~> 1.4'
|
30
30
|
end
|
31
31
|
rescue LoadError
|
data/lib/real_ex/client.rb
CHANGED
@@ -14,7 +14,7 @@ module RealEx
|
|
14
14
|
def build_xml(type, &block)
|
15
15
|
xml = Builder::XmlMarkup.new(:indent => 2)
|
16
16
|
xml.instruct!
|
17
|
-
xml.request(:
|
17
|
+
xml.request(:type => type, :timestamp => timestamp) { |r| block.call(r) }
|
18
18
|
xml.target!
|
19
19
|
end
|
20
20
|
|
data/lib/real_ex/config.rb
CHANGED
data/lib/real_ex/recurring.rb
CHANGED
@@ -3,7 +3,7 @@ module RealEx
|
|
3
3
|
|
4
4
|
class Transaction < RealEx::Transaction
|
5
5
|
def authorize!
|
6
|
-
RealEx::Response.new_from_xml(RealEx::Client.call(
|
6
|
+
RealEx::Response.new_from_xml(RealEx::Client.call(real_vault_uri, to_xml))
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
@@ -68,10 +68,16 @@ module RealEx
|
|
68
68
|
end
|
69
69
|
|
70
70
|
class Card < Transaction
|
71
|
-
attributes :card, :payer, :update, :reference
|
71
|
+
attributes :card, :payer, :update, :reference, :cancel
|
72
72
|
|
73
73
|
def request_type
|
74
|
-
|
74
|
+
if cancel
|
75
|
+
@request_type = 'card-cancel-card'
|
76
|
+
elsif update
|
77
|
+
@request_type = 'card-update-card'
|
78
|
+
else
|
79
|
+
@request_type = 'card-new'
|
80
|
+
end
|
75
81
|
end
|
76
82
|
|
77
83
|
def to_xml
|
@@ -89,8 +95,10 @@ module RealEx
|
|
89
95
|
|
90
96
|
# 20030516181127.yourmerchantid.uniqueid…smithj01.John Smith.498843******9991
|
91
97
|
def hash
|
92
|
-
if
|
93
|
-
RealEx::Client.build_hash([RealEx::Client.timestamp, RealEx::Config.merchant_id, payer.reference, reference
|
98
|
+
if cancel
|
99
|
+
RealEx::Client.build_hash([RealEx::Client.timestamp, RealEx::Config.merchant_id, payer.reference, reference])
|
100
|
+
elsif update
|
101
|
+
RealEx::Client.build_hash([RealEx::Client.timestamp, RealEx::Config.merchant_id, payer.reference, reference, card.expiry_date, card.number])
|
94
102
|
else
|
95
103
|
RealEx::Client.build_hash([RealEx::Client.timestamp, RealEx::Config.merchant_id, order_id, '', '', payer.reference,card.cardholder_name,card.number])
|
96
104
|
end
|
@@ -105,6 +113,11 @@ module RealEx
|
|
105
113
|
authorize!
|
106
114
|
end
|
107
115
|
|
116
|
+
def destroy!
|
117
|
+
self.cancel = true
|
118
|
+
authorize!
|
119
|
+
end
|
120
|
+
|
108
121
|
end
|
109
122
|
|
110
123
|
class Authorization < Transaction
|
data/lib/real_ex/transaction.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
module RealEx
|
2
2
|
class Transaction
|
3
3
|
include Initializer
|
4
|
-
attributes :card, :amount, :order_id, :currency, :autosettle, :variable_reference
|
4
|
+
attributes :card, :amount, :order_id, :currency, :autosettle, :variable_reference, :remote_uri, :real_vault_uri
|
5
5
|
attr_accessor :comments
|
6
6
|
attr_accessor :authcode, :pasref
|
7
7
|
|
8
|
-
REQUEST_TYPES = ['auth', 'manual', 'offline', 'tss', 'payer-new', 'payer-edit', 'card-new', '
|
8
|
+
REQUEST_TYPES = ['auth', 'manual', 'offline', 'tss', 'payer-new', 'payer-edit', 'card-new', 'card-update-card', 'card-cancel-card']
|
9
9
|
|
10
10
|
def initialize(hash = {})
|
11
11
|
super(hash)
|
12
12
|
self.comments ||= []
|
13
13
|
self.autosettle ||= true
|
14
14
|
self.currency ||= RealEx::Config.currency || 'EUR'
|
15
|
+
self.remote_uri ||= RealEx::Config.remote_uri || '/epage-remote.cgi'
|
16
|
+
self.real_vault_uri ||= RealEx::Config.real_vault_uri || '/epage-remote-plugins.cgi'
|
15
17
|
end
|
16
18
|
|
17
19
|
def request_type
|
@@ -48,7 +50,7 @@ module RealEx
|
|
48
50
|
end
|
49
51
|
|
50
52
|
def authorize!
|
51
|
-
RealEx::Response.new_from_xml(RealEx::Client.call(
|
53
|
+
RealEx::Response.new_from_xml(RealEx::Client.call(remote_uri, to_xml))
|
52
54
|
end
|
53
55
|
|
54
56
|
end
|
data/realex.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{realex}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.5"
|
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 = %q{2011-
|
11
|
+
s.authors = [%q{Paul Campbell}]
|
12
|
+
s.date = %q{2011-07-27}
|
13
13
|
s.description = %q{A Ruby library to make use of the payments API at http://realexpayments.com}
|
14
14
|
s.email = %q{paul@rslw.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -40,8 +40,8 @@ Gem::Specification.new do |s|
|
|
40
40
|
"spec/transaction_spec.rb"
|
41
41
|
]
|
42
42
|
s.homepage = %q{http://github.com/paulca/realex}
|
43
|
-
s.require_paths = [
|
44
|
-
s.rubygems_version = %q{1.5
|
43
|
+
s.require_paths = [%q{lib}]
|
44
|
+
s.rubygems_version = %q{1.8.5}
|
45
45
|
s.summary = %q{Ruby interface to http://realexpayments.com}
|
46
46
|
s.test_files = [
|
47
47
|
"spec/address_spec.rb",
|
data/spec/recurring_spec.rb
CHANGED
@@ -43,9 +43,14 @@ describe "RealEx::Recurring" do
|
|
43
43
|
|
44
44
|
it "should create lovely XML for the card update" do
|
45
45
|
@card.update = true
|
46
|
-
@card.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<request type=\"
|
46
|
+
@card.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<request type=\"card-update-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 <number>4111111111111111</number>\n <expdate>0802</expdate>\n <chname>Paul Campbell</chname>\n <type>VISA</type>\n </card>\n <sha1hash>cdcb4dd95d0d61d7c86685b1e465796ea55bdcea</sha1hash>\n</request>\n"
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
|
+
it "should create lovely XML for the card cancel" do
|
50
|
+
@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 <number>4111111111111111</number>\n <expdate>0802</expdate>\n <chname>Paul Campbell</chname>\n <type>VISA</type>\n </card>\n <sha1hash>d21f7cb5de344456c235d93b5f7c311bb70069ea</sha1hash>\n</request>\n"
|
52
|
+
end
|
53
|
+
|
49
54
|
it "should create tasty XML for the authorization" do
|
50
55
|
@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"
|
51
56
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: realex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 5
|
10
|
+
version: 0.3.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Paul Campbell
|
@@ -15,12 +15,10 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-07-27 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
22
|
none: false
|
25
23
|
requirements:
|
26
24
|
- - ">="
|
@@ -29,12 +27,12 @@ dependencies:
|
|
29
27
|
segments:
|
30
28
|
- 0
|
31
29
|
version: "0"
|
32
|
-
|
33
|
-
|
30
|
+
type: :runtime
|
31
|
+
requirement: *id001
|
34
32
|
prerelease: false
|
33
|
+
name: nokogiri
|
35
34
|
- !ruby/object:Gem::Dependency
|
36
|
-
|
37
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
35
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
36
|
none: false
|
39
37
|
requirements:
|
40
38
|
- - ">="
|
@@ -43,12 +41,12 @@ dependencies:
|
|
43
41
|
segments:
|
44
42
|
- 0
|
45
43
|
version: "0"
|
46
|
-
|
47
|
-
|
44
|
+
type: :runtime
|
45
|
+
requirement: *id002
|
48
46
|
prerelease: false
|
47
|
+
name: builder
|
49
48
|
- !ruby/object:Gem::Dependency
|
50
|
-
|
51
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
49
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
52
50
|
none: false
|
53
51
|
requirements:
|
54
52
|
- - ">="
|
@@ -57,12 +55,12 @@ dependencies:
|
|
57
55
|
segments:
|
58
56
|
- 0
|
59
57
|
version: "0"
|
60
|
-
|
61
|
-
|
58
|
+
type: :development
|
59
|
+
requirement: *id003
|
62
60
|
prerelease: false
|
61
|
+
name: jeweler
|
63
62
|
- !ruby/object:Gem::Dependency
|
64
|
-
|
65
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
63
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
66
64
|
none: false
|
67
65
|
requirements:
|
68
66
|
- - ~>
|
@@ -72,9 +70,10 @@ dependencies:
|
|
72
70
|
- 1
|
73
71
|
- 4
|
74
72
|
version: "1.4"
|
75
|
-
|
76
|
-
|
73
|
+
type: :runtime
|
74
|
+
requirement: *id004
|
77
75
|
prerelease: false
|
76
|
+
name: nokogiri
|
78
77
|
description: A Ruby library to make use of the payments API at http://realexpayments.com
|
79
78
|
email: paul@rslw.com
|
80
79
|
executables: []
|
@@ -106,7 +105,6 @@ files:
|
|
106
105
|
- spec/spec.opts
|
107
106
|
- spec/spec_helper.rb
|
108
107
|
- spec/transaction_spec.rb
|
109
|
-
has_rdoc: true
|
110
108
|
homepage: http://github.com/paulca/realex
|
111
109
|
licenses: []
|
112
110
|
|
@@ -136,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
134
|
requirements: []
|
137
135
|
|
138
136
|
rubyforge_project:
|
139
|
-
rubygems_version: 1.5
|
137
|
+
rubygems_version: 1.8.5
|
140
138
|
signing_key:
|
141
139
|
specification_version: 3
|
142
140
|
summary: Ruby interface to http://realexpayments.com
|