datatrans 2.3.1 → 2.4.0
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/.gitignore +0 -1
- data/.rspec +1 -0
- data/.rvmrc +1 -1
- data/.travis.yml +7 -0
- data/Gemfile.lock +68 -0
- data/README.markdown +6 -0
- data/Rakefile +4 -0
- data/datatrans.gemspec +5 -4
- data/lib/datatrans.rb +1 -0
- data/lib/datatrans/version.rb +1 -1
- data/lib/datatrans/xml/transaction/authorize.rb +18 -24
- data/lib/datatrans/xml/transaction/capture.rb +16 -22
- data/lib/datatrans/xml/transaction/request.rb +18 -6
- data/lib/datatrans/xml/transaction/response.rb +2 -2
- data/lib/datatrans/xml/transaction/status.rb +0 -1
- data/lib/datatrans/xml/transaction/void.rb +14 -20
- data/spec/common_spec.rb +3 -5
- data/spec/spec_helper.rb +6 -3
- data/spec/web/authorize_spec.rb +1 -1
- data/spec/xml/capture_spec.rb +30 -30
- data/spec/xml/request_spec.rb +33 -0
- data/spec/xml/void_spec.rb +30 -30
- metadata +131 -105
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format d --colour
|
data/.rvmrc
CHANGED
@@ -1 +1 @@
|
|
1
|
-
rvm ruby-1.9.
|
1
|
+
rvm ruby-1.9.3
|
data/.travis.yml
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
datatrans (2.4.0)
|
5
|
+
activesupport (>= 3.0.0)
|
6
|
+
builder
|
7
|
+
httparty
|
8
|
+
i18n
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: http://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actionpack (3.2.11)
|
14
|
+
activemodel (= 3.2.11)
|
15
|
+
activesupport (= 3.2.11)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
journey (~> 1.0.4)
|
19
|
+
rack (~> 1.4.0)
|
20
|
+
rack-cache (~> 1.2)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.2.1)
|
23
|
+
activemodel (3.2.11)
|
24
|
+
activesupport (= 3.2.11)
|
25
|
+
builder (~> 3.0.0)
|
26
|
+
activesupport (3.2.11)
|
27
|
+
i18n (~> 0.6)
|
28
|
+
multi_json (~> 1.0)
|
29
|
+
builder (3.0.4)
|
30
|
+
diff-lcs (1.1.3)
|
31
|
+
erubis (2.7.0)
|
32
|
+
hike (1.2.1)
|
33
|
+
httparty (0.10.2)
|
34
|
+
multi_json (~> 1.0)
|
35
|
+
multi_xml (>= 0.5.2)
|
36
|
+
i18n (0.6.1)
|
37
|
+
journey (1.0.4)
|
38
|
+
multi_json (1.5.0)
|
39
|
+
multi_xml (0.5.2)
|
40
|
+
rack (1.4.4)
|
41
|
+
rack-cache (1.2)
|
42
|
+
rack (>= 0.4)
|
43
|
+
rack-test (0.6.2)
|
44
|
+
rack (>= 1.0)
|
45
|
+
rake (10.0.3)
|
46
|
+
rspec (2.12.0)
|
47
|
+
rspec-core (~> 2.12.0)
|
48
|
+
rspec-expectations (~> 2.12.0)
|
49
|
+
rspec-mocks (~> 2.12.0)
|
50
|
+
rspec-core (2.12.2)
|
51
|
+
rspec-expectations (2.12.1)
|
52
|
+
diff-lcs (~> 1.1.3)
|
53
|
+
rspec-mocks (2.12.2)
|
54
|
+
sprockets (2.2.2)
|
55
|
+
hike (~> 1.2)
|
56
|
+
multi_json (~> 1.0)
|
57
|
+
rack (~> 1.0)
|
58
|
+
tilt (~> 1.1, != 1.3.0)
|
59
|
+
tilt (1.3.3)
|
60
|
+
|
61
|
+
PLATFORMS
|
62
|
+
ruby
|
63
|
+
|
64
|
+
DEPENDENCIES
|
65
|
+
actionpack (>= 3.0.0)
|
66
|
+
datatrans!
|
67
|
+
rake
|
68
|
+
rspec
|
data/README.markdown
CHANGED
@@ -12,6 +12,12 @@ Set your datatrans credentials in your environment.
|
|
12
12
|
config.merchant_id = '1234567'
|
13
13
|
config.sign_key = 'ab739fd5b7c2a1...'
|
14
14
|
config.environment = :production
|
15
|
+
config.proxy = {
|
16
|
+
:host => "proxy.com",
|
17
|
+
:port => 80,
|
18
|
+
:user => "hans",
|
19
|
+
:password => "xxx",
|
20
|
+
}
|
15
21
|
end
|
16
22
|
|
17
23
|
If you don't want to use signed requests (disabled in datatrans web console), you must set `config.sign_key` to `false`.
|
data/Rakefile
CHANGED
data/datatrans.gemspec
CHANGED
@@ -5,8 +5,8 @@ require "datatrans/version"
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "datatrans"
|
7
7
|
s.version = Datatrans::VERSION
|
8
|
-
s.authors = ["Tobias Miesel", "Thomas Maurer"]
|
9
|
-
s.email = ["tobias.miesel@simplificator.com", "thomas.maurer@simplificator.com"]
|
8
|
+
s.authors = ["Tobias Miesel", "Thomas Maurer", "Corin Langosch"]
|
9
|
+
s.email = ["tobias.miesel@simplificator.com", "thomas.maurer@simplificator.com", "corin.langosch@simplificator.com"]
|
10
10
|
s.homepage = ""
|
11
11
|
s.summary = %q{Datatrans Integration for Ruby on Rails}
|
12
12
|
s.description = %q{Datatrans Integration for Ruby on Rails}
|
@@ -17,12 +17,13 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
|
-
|
20
|
+
|
21
21
|
s.add_dependency 'httparty'
|
22
22
|
s.add_dependency 'activesupport', '>= 3.0.0'
|
23
23
|
s.add_dependency 'i18n'
|
24
24
|
s.add_dependency 'builder'
|
25
|
-
|
25
|
+
|
26
|
+
s.add_development_dependency 'rake'
|
26
27
|
s.add_development_dependency 'rspec'
|
27
28
|
s.add_development_dependency 'actionpack', '>= 3.0.0'
|
28
29
|
end
|
data/lib/datatrans.rb
CHANGED
data/lib/datatrans/version.rb
CHANGED
@@ -3,16 +3,14 @@ require 'datatrans/xml/transaction/response'
|
|
3
3
|
|
4
4
|
class Datatrans::XML::Transaction
|
5
5
|
class AuthorizeRequest < Request
|
6
|
-
|
7
6
|
def process
|
8
|
-
self.class.post(Datatrans.xml_authorize_url,
|
7
|
+
self.class.post(Datatrans.xml_authorize_url,
|
9
8
|
:headers => { 'Content-Type' => 'text/xml' },
|
10
9
|
:body => build_authorize_request.to_s).parsed_response
|
11
10
|
end
|
12
|
-
|
13
|
-
|
11
|
+
|
14
12
|
private
|
15
|
-
|
13
|
+
|
16
14
|
def build_authorize_request
|
17
15
|
build_xml_request(:authorization) do |xml|
|
18
16
|
xml.amount params[:amount]
|
@@ -23,31 +21,29 @@ class Datatrans::XML::Transaction
|
|
23
21
|
xml.sign sign(Datatrans.merchant_id, params[:amount], params[:currency], params[:refno])
|
24
22
|
end
|
25
23
|
end
|
26
|
-
|
27
24
|
end
|
28
|
-
|
25
|
+
|
29
26
|
class AuthorizeResponse < Response
|
30
|
-
|
31
27
|
def successful?
|
32
28
|
response_code == '01' && response_message == 'Authorized'
|
33
29
|
end
|
34
|
-
|
30
|
+
|
35
31
|
def response_code
|
36
32
|
params_root_node['response']['responseCode'] rescue nil
|
37
33
|
end
|
38
|
-
|
34
|
+
|
39
35
|
def response_message
|
40
36
|
params_root_node['response']['responseMessage'] rescue nil
|
41
37
|
end
|
42
|
-
|
38
|
+
|
43
39
|
def transaction_id
|
44
|
-
params_root_node['response']['uppTransactionId'] rescue nil
|
40
|
+
params_root_node['response']['uppTransactionId'] rescue nil
|
45
41
|
end
|
46
|
-
|
42
|
+
|
47
43
|
def reference_number
|
48
|
-
params_root_node['refno'] rescue nil
|
44
|
+
params_root_node['refno'] rescue nil
|
49
45
|
end
|
50
|
-
|
46
|
+
|
51
47
|
def authorization_code
|
52
48
|
params_root_node['response']['authorizationCode'] rescue nil
|
53
49
|
end
|
@@ -55,29 +51,27 @@ class Datatrans::XML::Transaction
|
|
55
51
|
def masked_cc
|
56
52
|
params_root_node['response']['maskedCC'] rescue nil
|
57
53
|
end
|
58
|
-
|
54
|
+
|
59
55
|
def creditcard_alias
|
60
56
|
params_root_node['request']['aliasCC'] rescue nil
|
61
57
|
end
|
62
|
-
|
58
|
+
|
63
59
|
def error_code
|
64
|
-
params_root_node['error']['errorCode'] rescue nil
|
60
|
+
params_root_node['error']['errorCode'] rescue nil
|
65
61
|
end
|
66
|
-
|
62
|
+
|
67
63
|
def error_message
|
68
64
|
params_root_node['error']['errorMessage'] rescue nil
|
69
65
|
end
|
70
|
-
|
66
|
+
|
71
67
|
def error_detail
|
72
68
|
params_root_node['error']['errorDetail'] rescue nil
|
73
69
|
end
|
74
|
-
|
75
|
-
|
70
|
+
|
76
71
|
private
|
77
|
-
|
72
|
+
|
78
73
|
def params_root_node
|
79
74
|
params['authorizationService']['body']['transaction']
|
80
75
|
end
|
81
|
-
|
82
76
|
end
|
83
77
|
end
|
@@ -3,16 +3,14 @@ require 'datatrans/xml/transaction/response'
|
|
3
3
|
|
4
4
|
class Datatrans::XML::Transaction
|
5
5
|
class CaptureRequest < Request
|
6
|
-
|
7
6
|
def process
|
8
|
-
self.class.post(Datatrans.xml_settlement_url,
|
7
|
+
self.class.post(Datatrans.xml_settlement_url,
|
9
8
|
:headers => { 'Content-Type' => 'text/xml' },
|
10
9
|
:body => build_capture_request.to_s).parsed_response
|
11
10
|
end
|
12
|
-
|
13
|
-
|
11
|
+
|
14
12
|
private
|
15
|
-
|
13
|
+
|
16
14
|
def build_capture_request
|
17
15
|
build_xml_request(:payment) do |xml|
|
18
16
|
xml.amount params[:amount]
|
@@ -20,49 +18,45 @@ class Datatrans::XML::Transaction
|
|
20
18
|
xml.uppTransactionId params[:transaction_id]
|
21
19
|
end
|
22
20
|
end
|
23
|
-
|
24
21
|
end
|
25
|
-
|
22
|
+
|
26
23
|
class CaptureResponse < Response
|
27
|
-
|
28
24
|
def successful?
|
29
25
|
response_code == '01' && response_message == 'settlement succeeded'
|
30
26
|
end
|
31
|
-
|
27
|
+
|
32
28
|
def response_code
|
33
29
|
params_root_node['response']['responseCode'] rescue nil
|
34
30
|
end
|
35
|
-
|
31
|
+
|
36
32
|
def response_message
|
37
33
|
params_root_node['response']['responseMessage'] rescue nil
|
38
34
|
end
|
39
|
-
|
35
|
+
|
40
36
|
def transaction_id
|
41
|
-
params_root_node['request']['uppTransactionId'] rescue nil
|
37
|
+
params_root_node['request']['uppTransactionId'] rescue nil
|
42
38
|
end
|
43
|
-
|
39
|
+
|
44
40
|
def reference_number
|
45
|
-
params_root_node['refno'] rescue nil
|
41
|
+
params_root_node['refno'] rescue nil
|
46
42
|
end
|
47
|
-
|
43
|
+
|
48
44
|
def error_code
|
49
|
-
params_root_node['error']['errorCode'] rescue nil
|
45
|
+
params_root_node['error']['errorCode'] rescue nil
|
50
46
|
end
|
51
|
-
|
47
|
+
|
52
48
|
def error_message
|
53
49
|
params_root_node['error']['errorMessage'] rescue nil
|
54
50
|
end
|
55
|
-
|
51
|
+
|
56
52
|
def error_detail
|
57
53
|
params_root_node['error']['errorDetail'] rescue nil
|
58
54
|
end
|
59
|
-
|
60
|
-
|
55
|
+
|
61
56
|
private
|
62
|
-
|
57
|
+
|
63
58
|
def params_root_node
|
64
59
|
params['paymentService']['body']['transaction']
|
65
60
|
end
|
66
|
-
|
67
61
|
end
|
68
62
|
end
|
@@ -2,11 +2,25 @@ require 'httparty'
|
|
2
2
|
require 'builder'
|
3
3
|
|
4
4
|
class Datatrans::XML::Transaction
|
5
|
-
class Request
|
5
|
+
class Request
|
6
6
|
include HTTParty
|
7
7
|
|
8
8
|
attr_accessor :params
|
9
|
-
|
9
|
+
|
10
|
+
def self.set_default_options
|
11
|
+
if Datatrans.proxy
|
12
|
+
proxy = Datatrans.proxy.symbolize_keys
|
13
|
+
http_proxy(proxy[:host], proxy[:port], proxy[:user], proxy[:password])
|
14
|
+
else
|
15
|
+
http_proxy(nil, nil, nil, nil)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.perform_request(*args, &block)
|
20
|
+
set_default_options
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
10
24
|
def initialize(params)
|
11
25
|
@params = params
|
12
26
|
end
|
@@ -14,10 +28,9 @@ class Datatrans::XML::Transaction
|
|
14
28
|
def process
|
15
29
|
raise 'overwrite in subclass!'
|
16
30
|
end
|
17
|
-
|
18
|
-
|
31
|
+
|
19
32
|
private
|
20
|
-
|
33
|
+
|
21
34
|
include Datatrans::Common
|
22
35
|
|
23
36
|
def build_xml_request(service)
|
@@ -34,6 +47,5 @@ class Datatrans::XML::Transaction
|
|
34
47
|
end
|
35
48
|
xml.target!
|
36
49
|
end
|
37
|
-
|
38
50
|
end
|
39
51
|
end
|
@@ -3,16 +3,14 @@ require 'datatrans/xml/transaction/response'
|
|
3
3
|
|
4
4
|
class Datatrans::XML::Transaction
|
5
5
|
class VoidRequest < Request
|
6
|
-
|
7
6
|
def process
|
8
|
-
self.class.post(Datatrans.xml_settlement_url,
|
7
|
+
self.class.post(Datatrans.xml_settlement_url,
|
9
8
|
:headers => { 'Content-Type' => 'text/xml' },
|
10
9
|
:body => build_void_request.to_s).parsed_response
|
11
10
|
end
|
12
|
-
|
13
|
-
|
11
|
+
|
14
12
|
private
|
15
|
-
|
13
|
+
|
16
14
|
def build_void_request
|
17
15
|
build_xml_request(:payment) do |xml|
|
18
16
|
xml.amount params[:amount]
|
@@ -21,49 +19,45 @@ class Datatrans::XML::Transaction
|
|
21
19
|
xml.reqtype 'DOA'
|
22
20
|
end
|
23
21
|
end
|
24
|
-
|
25
22
|
end
|
26
|
-
|
23
|
+
|
27
24
|
class VoidResponse < Response
|
28
|
-
|
29
25
|
def successful?
|
30
26
|
response_code == '01' && response_message == 'cancellation succeeded'
|
31
27
|
end
|
32
|
-
|
28
|
+
|
33
29
|
def response_code
|
34
30
|
params_root_node['response']['responseCode'] rescue nil
|
35
31
|
end
|
36
|
-
|
32
|
+
|
37
33
|
def response_message
|
38
34
|
params_root_node['response']['responseMessage'] rescue nil
|
39
35
|
end
|
40
|
-
|
36
|
+
|
41
37
|
def transaction_id
|
42
38
|
params_root_node['request']['uppTransactionId'] rescue nil
|
43
39
|
end
|
44
|
-
|
40
|
+
|
45
41
|
def reference_number
|
46
|
-
params_root_node['refno'] rescue nil
|
42
|
+
params_root_node['refno'] rescue nil
|
47
43
|
end
|
48
|
-
|
44
|
+
|
49
45
|
def error_code
|
50
46
|
params_root_node['error']['errorCode'] rescue nil
|
51
47
|
end
|
52
|
-
|
48
|
+
|
53
49
|
def error_message
|
54
50
|
params_root_node['error']['errorMessage'] rescue nil
|
55
51
|
end
|
56
|
-
|
52
|
+
|
57
53
|
def error_detail
|
58
54
|
params_root_node['error']['errorDetail'] rescue nil
|
59
55
|
end
|
60
|
-
|
61
|
-
|
56
|
+
|
62
57
|
private
|
63
|
-
|
58
|
+
|
64
59
|
def params_root_node
|
65
60
|
params['paymentService']['body']['transaction']
|
66
61
|
end
|
67
|
-
|
68
62
|
end
|
69
63
|
end
|
data/spec/common_spec.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Datatrans::Common do
|
4
|
-
|
5
4
|
context "sign" do
|
6
5
|
before do
|
7
6
|
class Request; include Datatrans::Common; end
|
8
7
|
@request = Request.new
|
9
8
|
end
|
10
|
-
|
9
|
+
|
11
10
|
it "generates the correct sign" do
|
12
11
|
amount = 1000
|
13
12
|
currency = 'CHF'
|
14
13
|
reference_number = 'ABCEDF'
|
15
|
-
|
14
|
+
|
16
15
|
@request.sign(Datatrans.merchant_id, amount, currency, reference_number).should == '4e7d4d5bbde548c586f3b7f109635ffc'
|
17
16
|
end
|
18
17
|
end
|
19
|
-
|
20
|
-
end
|
18
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler/setup'
|
3
3
|
|
4
|
+
require 'active_support'
|
4
5
|
require 'datatrans'
|
5
6
|
|
6
7
|
RSpec.configure do |config|
|
7
|
-
|
8
|
+
config.filter_run :focus => true
|
9
|
+
config.filter_run_excluding :skip => true
|
10
|
+
config.run_all_when_everything_filtered = true
|
11
|
+
|
8
12
|
config.before(:each) do
|
9
13
|
Datatrans.configure do |config|
|
10
14
|
config.merchant_id = '1100000000'
|
@@ -12,5 +16,4 @@ RSpec.configure do |config|
|
|
12
16
|
config.environment = :development
|
13
17
|
end
|
14
18
|
end
|
15
|
-
|
16
|
-
end
|
19
|
+
end
|
data/spec/web/authorize_spec.rb
CHANGED
@@ -74,7 +74,7 @@ describe Datatrans::Web::Transaction do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
it "should generate valid form field string" do
|
77
|
-
@view.datatrans_notification_request_hidden_fields(@transaction).should == "<input id=\"merchantId\" name=\"merchantId\" type=\"hidden\" value=\"1100000000\" /><input id=\"hiddenMode\" name=\"hiddenMode\" type=\"hidden\" value=\"yes\" /><input id=\"reqtype\" name=\"reqtype\" type=\"hidden\" value=\"NOA\" /><input id=\"amount\" name=\"amount\" type=\"hidden\" value=\"1000\" /><input id=\"currency\" name=\"currency\" type=\"hidden\" value=\"CHF\" /><input id=\"useAlias\" name=\"useAlias\" type=\"hidden\" value=\"yes\" /><input id=\"sign\" name=\"sign\" type=\"hidden\" value=\"0402fb3fba8c6fcb40df9b7756e7e637\" /><input id=\"refno\" name=\"refno\" type=\"hidden\" value=\"ABCDEF\" /><input id=\"uppCustomerEmail\" name=\"uppCustomerEmail\" type=\"hidden\" value=\"customer@email.com\" />"
|
77
|
+
@view.datatrans_notification_request_hidden_fields(@transaction).should == "<input id=\"merchantId\" name=\"merchantId\" type=\"hidden\" value=\"1100000000\" /><input id=\"hiddenMode\" name=\"hiddenMode\" type=\"hidden\" value=\"yes\" /><input id=\"reqtype\" name=\"reqtype\" type=\"hidden\" value=\"NOA\" /><input id=\"amount\" name=\"amount\" type=\"hidden\" value=\"1000\" /><input id=\"currency\" name=\"currency\" type=\"hidden\" value=\"CHF\" /><input id=\"useAlias\" name=\"useAlias\" type=\"hidden\" value=\"yes\" /><input id=\"sign\" name=\"sign\" type=\"hidden\" value=\"0402fb3fba8c6fcb40df9b7756e7e637\" /><input id=\"refno\" name=\"refno\" type=\"hidden\" value=\"ABCDEF\" /><input id=\"uppCustomerDetails\" name=\"uppCustomerDetails\" type=\"hidden\" /><input id=\"uppCustomerEmail\" name=\"uppCustomerEmail\" type=\"hidden\" value=\"customer@email.com\" />"
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
data/spec/xml/capture_spec.rb
CHANGED
@@ -7,52 +7,52 @@ describe Datatrans::XML::Transaction::CaptureRequest do
|
|
7
7
|
"body" => {
|
8
8
|
"transaction" => {
|
9
9
|
"request" => {
|
10
|
-
"amount" => "1000",
|
11
|
-
"currency" => "CHF",
|
12
|
-
"uppTransactionId" => "110808142256858007",
|
13
|
-
"reqtype" => "COA",
|
10
|
+
"amount" => "1000",
|
11
|
+
"currency" => "CHF",
|
12
|
+
"uppTransactionId" => "110808142256858007",
|
13
|
+
"reqtype" => "COA",
|
14
14
|
"transtype" => "05"
|
15
|
-
},
|
15
|
+
},
|
16
16
|
"response" => {
|
17
|
-
"responseCode" => "01",
|
17
|
+
"responseCode" => "01",
|
18
18
|
"responseMessage" => "settlement succeeded"
|
19
|
-
},
|
20
|
-
"refno" => "ABCDEF",
|
19
|
+
},
|
20
|
+
"refno" => "ABCDEF",
|
21
21
|
"trxStatus" => "response"
|
22
|
-
},
|
23
|
-
"merchantId" => "1100001872",
|
22
|
+
},
|
23
|
+
"merchantId" => "1100001872",
|
24
24
|
"status" => "accepted"
|
25
|
-
},
|
25
|
+
},
|
26
26
|
"version" => "1"
|
27
27
|
}
|
28
28
|
}
|
29
|
-
|
29
|
+
|
30
30
|
@failed_response = {
|
31
31
|
"paymentService" => {
|
32
32
|
"body" => {
|
33
33
|
"transaction" => {
|
34
34
|
"request" => {
|
35
|
-
"amount" => "1000",
|
36
|
-
"currency" => "CHF",
|
37
|
-
"uppTransactionId" => "110808143302868124",
|
38
|
-
"reqtype" => "DOA",
|
35
|
+
"amount" => "1000",
|
36
|
+
"currency" => "CHF",
|
37
|
+
"uppTransactionId" => "110808143302868124",
|
38
|
+
"reqtype" => "DOA",
|
39
39
|
"transtype" => "05"
|
40
|
-
},
|
40
|
+
},
|
41
41
|
"error" => {
|
42
|
-
"errorCode" => "1010",
|
43
|
-
"errorMessage" => "cannot be settled",
|
42
|
+
"errorCode" => "1010",
|
43
|
+
"errorMessage" => "cannot be settled",
|
44
44
|
"errorDetail" => "trx has another as authorized status: 92"
|
45
45
|
},
|
46
|
-
"refno" => "ABCDEF",
|
46
|
+
"refno" => "ABCDEF",
|
47
47
|
"trxStatus" => "response"
|
48
|
-
},
|
49
|
-
"merchantId" => "1100001872",
|
48
|
+
},
|
49
|
+
"merchantId" => "1100001872",
|
50
50
|
"status" => "accepted"
|
51
|
-
},
|
51
|
+
},
|
52
52
|
"version" => "1"
|
53
53
|
}
|
54
54
|
}
|
55
|
-
|
55
|
+
|
56
56
|
@valid_params = {
|
57
57
|
:refno => 'ABCDEF',
|
58
58
|
:amount => 1000,
|
@@ -60,19 +60,19 @@ describe Datatrans::XML::Transaction::CaptureRequest do
|
|
60
60
|
:transaction_id => '110808142256858007'
|
61
61
|
}
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
context "successful response" do
|
65
65
|
before do
|
66
66
|
Datatrans::XML::Transaction::CaptureRequest.any_instance.stub(:process).and_return(@successful_response)
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
context "build_capture_request" do
|
70
70
|
it "generates a valid datatrans capture xml" do
|
71
71
|
@request = Datatrans::XML::Transaction::CaptureRequest.new(@valid_params)
|
72
72
|
@request.send(:build_capture_request).should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><paymentService version=\"1\"><body merchantId=\"1100000000\"><transaction refno=\"ABCDEF\"><request><amount>1000</amount><currency>CHF</currency><uppTransactionId>110808142256858007</uppTransactionId></request></transaction></body></paymentService>"
|
73
73
|
end
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
context "process" do
|
77
77
|
it "handles a valid datatrans capture response" do
|
78
78
|
@transaction = Datatrans::XML::Transaction.new(@valid_params)
|
@@ -80,18 +80,18 @@ describe Datatrans::XML::Transaction::CaptureRequest do
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
context "failed response" do
|
85
85
|
before do
|
86
86
|
Datatrans::XML::Transaction::CaptureRequest.any_instance.stub(:process).and_return(@failed_response)
|
87
87
|
@transaction = Datatrans::XML::Transaction.new(@valid_params)
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
context "process" do
|
91
91
|
it "handles a failed datatrans capture response" do
|
92
92
|
@transaction.capture.should be_false
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
it "returns error details" do
|
96
96
|
@transaction.capture
|
97
97
|
@transaction.error_code.length.should > 0
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Datatrans::XML::Transaction::Request do
|
4
|
+
describe "ClassMethods" do
|
5
|
+
describe "set_default_options" do
|
6
|
+
it "should set the current proxy settings" do
|
7
|
+
Datatrans.configure do |config|
|
8
|
+
config.proxy = {
|
9
|
+
:host => "test.com",
|
10
|
+
:port => 123,
|
11
|
+
:user => "hans",
|
12
|
+
:password => "wurst",
|
13
|
+
}
|
14
|
+
end
|
15
|
+
Datatrans::XML::Transaction::Request.should_receive(:http_proxy).with(Datatrans.proxy[:host], Datatrans.proxy[:port], Datatrans.proxy[:user], Datatrans.proxy[:password])
|
16
|
+
Datatrans::XML::Transaction::Request.set_default_options
|
17
|
+
|
18
|
+
Datatrans.configure do |config|
|
19
|
+
config.proxy = nil
|
20
|
+
end
|
21
|
+
Datatrans::XML::Transaction::Request.should_receive(:http_proxy).with(nil, nil, nil, nil)
|
22
|
+
Datatrans::XML::Transaction::Request.set_default_options
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "post" do
|
27
|
+
it "should update the default options and perform the request afterwards" do
|
28
|
+
Datatrans::XML::Transaction::Request.should_receive(:set_default_options)
|
29
|
+
Datatrans::XML::Transaction::Request.perform_request(Net::HTTP::Post, "http://example.com", :a => "b")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/xml/void_spec.rb
CHANGED
@@ -7,52 +7,52 @@ describe Datatrans::XML::Transaction::VoidRequest do
|
|
7
7
|
"body" => {
|
8
8
|
"transaction" => {
|
9
9
|
"request" => {
|
10
|
-
"amount" => "1000",
|
11
|
-
"currency" => "CHF",
|
12
|
-
"uppTransactionId" => "110808143302868124",
|
13
|
-
"reqtype" => "DOA",
|
10
|
+
"amount" => "1000",
|
11
|
+
"currency" => "CHF",
|
12
|
+
"uppTransactionId" => "110808143302868124",
|
13
|
+
"reqtype" => "DOA",
|
14
14
|
"transtype" => "05"
|
15
|
-
},
|
15
|
+
},
|
16
16
|
"response" => {
|
17
|
-
"responseCode" => "01",
|
17
|
+
"responseCode" => "01",
|
18
18
|
"responseMessage" => "cancellation succeeded"
|
19
|
-
},
|
20
|
-
"refno" => "ABCDEF",
|
19
|
+
},
|
20
|
+
"refno" => "ABCDEF",
|
21
21
|
"trxStatus" => "response"
|
22
|
-
},
|
23
|
-
"merchantId" => "1100001872",
|
22
|
+
},
|
23
|
+
"merchantId" => "1100001872",
|
24
24
|
"status" => "accepted"
|
25
|
-
},
|
25
|
+
},
|
26
26
|
"version" => "1"
|
27
27
|
}
|
28
28
|
}
|
29
|
-
|
29
|
+
|
30
30
|
@failed_response = {
|
31
31
|
"paymentService" => {
|
32
32
|
"body" => {
|
33
33
|
"transaction" => {
|
34
34
|
"request" => {
|
35
|
-
"amount" => "1000",
|
36
|
-
"currency" => "CHF",
|
37
|
-
"uppTransactionId" => "110808143302868124",
|
38
|
-
"reqtype" => "DOA",
|
35
|
+
"amount" => "1000",
|
36
|
+
"currency" => "CHF",
|
37
|
+
"uppTransactionId" => "110808143302868124",
|
38
|
+
"reqtype" => "DOA",
|
39
39
|
"transtype" => "05"
|
40
|
-
},
|
40
|
+
},
|
41
41
|
"error" => {
|
42
|
-
"errorCode" => "1010",
|
43
|
-
"errorMessage" => "cannot be canceled",
|
42
|
+
"errorCode" => "1010",
|
43
|
+
"errorMessage" => "cannot be canceled",
|
44
44
|
"errorDetail" => "trx has not corresponding status: 82"
|
45
45
|
},
|
46
|
-
"refno" => "ABCDEF",
|
46
|
+
"refno" => "ABCDEF",
|
47
47
|
"trxStatus" => "response"
|
48
|
-
},
|
49
|
-
"merchantId" => "1100001872",
|
48
|
+
},
|
49
|
+
"merchantId" => "1100001872",
|
50
50
|
"status" => "accepted"
|
51
|
-
},
|
51
|
+
},
|
52
52
|
"version" => "1"
|
53
53
|
}
|
54
54
|
}
|
55
|
-
|
55
|
+
|
56
56
|
@valid_params = {
|
57
57
|
:refno => 'ABCDEF',
|
58
58
|
:amount => 1000,
|
@@ -60,19 +60,19 @@ describe Datatrans::XML::Transaction::VoidRequest do
|
|
60
60
|
:transaction_id => '110808143302868124'
|
61
61
|
}
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
context "successful response" do
|
65
65
|
before do
|
66
66
|
Datatrans::XML::Transaction::VoidRequest.any_instance.stub(:process).and_return(@successful_response)
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
context "build_void_request" do
|
70
70
|
it "generates a valid datatrans void xml" do
|
71
71
|
@request = Datatrans::XML::Transaction::VoidRequest.new(@valid_params)
|
72
72
|
@request.send(:build_void_request).should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><paymentService version=\"1\"><body merchantId=\"1100000000\"><transaction refno=\"ABCDEF\"><request><amount>1000</amount><currency>CHF</currency><uppTransactionId>110808143302868124</uppTransactionId><reqtype>DOA</reqtype></request></transaction></body></paymentService>"
|
73
73
|
end
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
context "process" do
|
77
77
|
it "handles a valid datatrans void response" do
|
78
78
|
@transaction = Datatrans::XML::Transaction.new(@valid_params)
|
@@ -80,18 +80,18 @@ describe Datatrans::XML::Transaction::VoidRequest do
|
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
context "failed response" do
|
85
85
|
before do
|
86
86
|
Datatrans::XML::Transaction::VoidRequest.any_instance.stub(:process).and_return(@failed_response)
|
87
87
|
@transaction = Datatrans::XML::Transaction.new(@valid_params)
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
context "process" do
|
91
91
|
it "handles a failed datatrans void response" do
|
92
92
|
@transaction.void.should be_false
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
it "returns error details" do
|
96
96
|
@transaction.void
|
97
97
|
@transaction.error_code.length.should > 0
|
metadata
CHANGED
@@ -1,113 +1,145 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: datatrans
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 2
|
7
|
-
- 3
|
8
|
-
- 1
|
9
|
-
version: 2.3.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.4.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Tobias Miesel
|
13
9
|
- Thomas Maurer
|
10
|
+
- Corin Langosch
|
14
11
|
autorequire:
|
15
12
|
bindir: bin
|
16
13
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
14
|
+
date: 2013-01-28 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
none: false
|
23
|
+
type: :runtime
|
22
24
|
name: httparty
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
none: false
|
23
31
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 3.0.0
|
38
|
+
none: false
|
31
39
|
type: :runtime
|
32
|
-
version_requirements: *id001
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
40
|
name: activesupport
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
segments:
|
41
|
-
- 3
|
42
|
-
- 0
|
43
|
-
- 0
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
44
45
|
version: 3.0.0
|
46
|
+
none: false
|
47
|
+
prerelease: false
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
none: false
|
45
55
|
type: :runtime
|
46
|
-
version_requirements: *id002
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
56
|
name: i18n
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
none: false
|
49
63
|
prerelease: false
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
none: false
|
57
71
|
type: :runtime
|
58
|
-
version_requirements: *id003
|
59
|
-
- !ruby/object:Gem::Dependency
|
60
72
|
name: builder
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
none: false
|
61
79
|
prerelease: false
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
type: :
|
70
|
-
|
71
|
-
|
72
|
-
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
none: false
|
87
|
+
type: :development
|
88
|
+
name: rake
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
none: false
|
73
95
|
prerelease: false
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
none: false
|
81
103
|
type: :development
|
82
|
-
|
83
|
-
|
84
|
-
|
104
|
+
name: rspec
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
none: false
|
85
111
|
prerelease: false
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
- 3
|
92
|
-
- 0
|
93
|
-
- 0
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
94
117
|
version: 3.0.0
|
118
|
+
none: false
|
95
119
|
type: :development
|
96
|
-
|
120
|
+
name: actionpack
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 3.0.0
|
126
|
+
none: false
|
127
|
+
prerelease: false
|
97
128
|
description: Datatrans Integration for Ruby on Rails
|
98
|
-
email:
|
129
|
+
email:
|
99
130
|
- tobias.miesel@simplificator.com
|
100
131
|
- thomas.maurer@simplificator.com
|
132
|
+
- corin.langosch@simplificator.com
|
101
133
|
executables: []
|
102
|
-
|
103
134
|
extensions: []
|
104
|
-
|
105
135
|
extra_rdoc_files: []
|
106
|
-
|
107
|
-
files:
|
136
|
+
files:
|
108
137
|
- .gitignore
|
138
|
+
- .rspec
|
109
139
|
- .rvmrc
|
140
|
+
- .travis.yml
|
110
141
|
- Gemfile
|
142
|
+
- Gemfile.lock
|
111
143
|
- README.markdown
|
112
144
|
- Rakefile
|
113
145
|
- datatrans.gemspec
|
@@ -128,43 +160,37 @@ files:
|
|
128
160
|
- spec/web/authorize_spec.rb
|
129
161
|
- spec/xml/authorize_spec.rb
|
130
162
|
- spec/xml/capture_spec.rb
|
163
|
+
- spec/xml/request_spec.rb
|
131
164
|
- spec/xml/status_spec.rb
|
132
165
|
- spec/xml/void_spec.rb
|
133
|
-
|
134
|
-
homepage: ""
|
166
|
+
homepage: ''
|
135
167
|
licenses: []
|
136
|
-
|
137
168
|
post_install_message:
|
138
169
|
rdoc_options: []
|
139
|
-
|
140
|
-
require_paths:
|
170
|
+
require_paths:
|
141
171
|
- lib
|
142
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
-
requirements:
|
144
|
-
- -
|
145
|
-
- !ruby/object:Gem::Version
|
146
|
-
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ! '>='
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
hash: -136247163122496527
|
177
|
+
version: '0'
|
178
|
+
segments:
|
147
179
|
- 0
|
148
|
-
|
149
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
-
requirements:
|
151
|
-
- -
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
|
180
|
+
none: false
|
181
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ! '>='
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
hash: -136247163122496527
|
186
|
+
version: '0'
|
187
|
+
segments:
|
154
188
|
- 0
|
155
|
-
|
189
|
+
none: false
|
156
190
|
requirements: []
|
157
|
-
|
158
191
|
rubyforge_project: datatrans
|
159
|
-
rubygems_version: 1.
|
192
|
+
rubygems_version: 1.8.24
|
160
193
|
signing_key:
|
161
194
|
specification_version: 3
|
162
195
|
summary: Datatrans Integration for Ruby on Rails
|
163
|
-
test_files:
|
164
|
-
- spec/common_spec.rb
|
165
|
-
- spec/spec_helper.rb
|
166
|
-
- spec/web/authorize_spec.rb
|
167
|
-
- spec/xml/authorize_spec.rb
|
168
|
-
- spec/xml/capture_spec.rb
|
169
|
-
- spec/xml/status_spec.rb
|
170
|
-
- spec/xml/void_spec.rb
|
196
|
+
test_files: []
|