wirecardmapper 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +56 -7
- data/Rakefile +14 -30
- data/lib/wirecardmapper.rb +93 -27
- data/lib/wirecardmapper/config.rb +12 -3
- data/lib/wirecardmapper/exception.rb +5 -0
- data/lib/wirecardmapper/models/base.rb +117 -0
- data/lib/wirecardmapper/models/mongo_mapper.rb +28 -0
- data/lib/wirecardmapper/railtie.rb +20 -0
- data/lib/wirecardmapper/response.rb +32 -17
- data/lib/wirecardmapper/version.rb +1 -1
- data/spec/fixtures/config/wirecardmapper.yml +12 -0
- data/spec/fixtures/create_card.xml +1 -1
- data/spec/fixtures/create_card_without_card_id.xml +34 -0
- data/spec/fixtures/get_card_info.xml +46 -0
- data/spec/fixtures/wirecard_server_down.xml +42 -0
- data/spec/functional/models/base_spec.rb +85 -0
- data/spec/functional/models/mongo_mapper_spec.rb +30 -0
- data/spec/functional/wirecardmapper_spec.rb +104 -0
- data/spec/spec_helper.rb +27 -6
- data/spec/unit/config_spec.rb +75 -0
- data/spec/unit/request_spec.rb +57 -0
- data/spec/unit/response_spec.rb +20 -7
- metadata +144 -83
- data/LICENSE +0 -20
- data/lib/wirecardmapper/net_http_monkeypatch.rb +0 -8
- data/lib/wirecardmapper/xml.rb +0 -43
- data/spec/functional/request_spec.rb +0 -58
- data/templates/change_card_status.xml +0 -7
- data/templates/create_card.xml +0 -8
- data/templates/get_card_info.xml +0 -6
- data/templates/get_payment_info.xml +0 -11
- data/templates/main.xml +0 -7
- data/templates/submit_payment.xml +0 -10
- data/templates/update_card_info.xml +0 -6
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2010 Alexander Klaiber
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/wirecardmapper/xml.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
module WirecardMapper
|
2
|
-
module Xml
|
3
|
-
|
4
|
-
def main_xml
|
5
|
-
xml = open_xml('main.xml')
|
6
|
-
if xml
|
7
|
-
xml.at_css("issuer-request")['mode'] = Config.mode
|
8
|
-
xml.at_css("request-id").content = request_id
|
9
|
-
xml.at_css("entity-id").content = Config.entity_id
|
10
|
-
end
|
11
|
-
return xml
|
12
|
-
end
|
13
|
-
|
14
|
-
def sub_xml(name, params)
|
15
|
-
xml = open_xml(name)
|
16
|
-
xml.at_css("product-id").content = Config.product_id if xml.at_css("product-id")
|
17
|
-
params.each do |param, value|
|
18
|
-
if xml.at_css(param.to_s.gsub(/_/,'-'))
|
19
|
-
if value.kind_of?(Time)
|
20
|
-
xml.at_css(param.to_s.gsub(/_/,'-')).content = value.iso8601
|
21
|
-
else
|
22
|
-
xml.at_css(param.to_s.gsub(/_/,'-')).content = value
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
yield xml
|
27
|
-
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def request_id
|
32
|
-
UUID.generate
|
33
|
-
end
|
34
|
-
|
35
|
-
def open_xml(file_name)
|
36
|
-
xml_file = File.open(File.join(Config.templates_path, file_name))
|
37
|
-
if xml_file
|
38
|
-
return Nokogiri::XML(xml_file)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe 'Request' do
|
4
|
-
|
5
|
-
it "should get cardinfo" do
|
6
|
-
response = WirecardMapper.card_info(:card_id => '47ae07020a010018157db66065da6e5c')
|
7
|
-
response.ok?.should be_true
|
8
|
-
response.card_id.should eql('47ae07020a010018157db66065da6e5c')
|
9
|
-
response.card_number.should eql(5274569796581777)
|
10
|
-
response.balance.should eql(200)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should create card" do
|
14
|
-
response = WirecardMapper.create_card
|
15
|
-
response.ok?.should be_true
|
16
|
-
response.card_id.should_not be_empty
|
17
|
-
response.card_number.should_not be_nil
|
18
|
-
response.status_message.should eql('Active card')
|
19
|
-
response.status_code.should eql('activated')
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should update card info" do
|
23
|
-
response = WirecardMapper.update_card_info(:card_id => '47ae07020a010018157db66065da6e5c')
|
24
|
-
response.ok?.should be_true
|
25
|
-
response.return_code.to_i.should eql(0)
|
26
|
-
response.return_message.should eql('Successful system entry.')
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should submit payment load" do
|
30
|
-
response = WirecardMapper.submit_payment(:card_id => '47ae07020a010018157db66065da6e5c', :amount => 10, :payment_comment => "Test Comment")
|
31
|
-
response.ok?.should be_true
|
32
|
-
response.return_code.to_i.should eql(0)
|
33
|
-
response.return_message.should eql('Successful system entry.')
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should submit payment unload" do
|
37
|
-
response = WirecardMapper.submit_payment(:card_id => '47ae07020a010018157db66065da6e5c', :amount => -10, :payment_comment => "Test Comment")
|
38
|
-
response.ok?.should be_true
|
39
|
-
response.return_code.to_i.should eql(0)
|
40
|
-
response.return_message.should eql('Successful system entry.')
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should get payment info" do
|
44
|
-
response = WirecardMapper.payment_info(:card_id => '47ae07020a010018157db66065da6e5c', :from => Time.now - (24 * 3600), :to => Time.now)
|
45
|
-
response.ok?.should be_true
|
46
|
-
response.return_code.to_i.should eql(0)
|
47
|
-
response.return_message.should eql('Successful system entry.')
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should change card status" do
|
51
|
-
response = WirecardMapper.change_card_status(:card_id => '47ae07020a010018157db66065da6e5c', :status_code => 'cancelled')
|
52
|
-
response.ok?.should be_true
|
53
|
-
response.return_code.to_i.should eql(0)
|
54
|
-
response.return_message.should eql('Successful system entry.')
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
|
data/templates/create_card.xml
DELETED
data/templates/get_card_info.xml
DELETED
data/templates/main.xml
DELETED