global_collect 0.1.1 → 0.1.2

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.
Files changed (26) hide show
  1. data/.gitignore +2 -0
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/examples/support_helper_ex.rb +21 -0
  5. data/global_collect.gemspec +16 -11
  6. data/lib/global_collect/api_client.rb +0 -2
  7. data/spec/api_client_spec.rb +5 -5
  8. data/spec/responses/base_spec.rb +2 -2
  9. data/spec/responses/convert_amount/response_methods_spec.rb +1 -1
  10. data/spec/responses/do_refund/response_methods_spec.rb +1 -1
  11. data/spec/responses/get_order_status/v1_response_methods_spec.rb +1 -1
  12. data/spec/responses/get_order_status/v2_response_methods_spec.rb +1 -1
  13. data/spec/responses/insert_order_with_payment/credit_card_online_payment_response_methods_spec.rb +1 -1
  14. data/spec/responses/insert_order_with_payment/hosted_merchant_link_payment_response_methods_spec.rb +1 -1
  15. data/spec/responses/succcess_row_spec.rb +2 -2
  16. data/spec/spec_helper.rb +4 -10
  17. data/spec/support/{challenged_iowp_response.xml → challenged_iowp_v1_response.xml} +0 -0
  18. data/spec/support/{successful_convert_amount_response.xml → successful_convert_amount_v1_response.xml} +0 -0
  19. data/spec/support/{successful_do_refund_response.xml → successful_do_refund_v1_response.xml} +0 -0
  20. data/spec/support/{successful_hosted_iowp_response.xml → successful_hosted_iowp_v1_response.xml} +0 -0
  21. data/spec/support/{successful_iowp_response.xml → successful_iowp_v1_response.xml} +0 -0
  22. data/spec/support/support_helper.rb +25 -0
  23. data/spec/support/{unsuccessful_do_refund_response.xml → unsuccessful_do_refund_v1_response.xml} +0 -0
  24. data/spec/support/{unsuccessful_iowp_response.xml → unsuccessful_iowp_v1_response.xml} +0 -0
  25. data/spec/support/{unsuccessful_process_challenged_response.xml → unsuccessful_process_challenged_v1_response.xml} +0 -0
  26. metadata +16 -11
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /pkg
2
+ /doc
data/Rakefile CHANGED
@@ -24,7 +24,7 @@ END
24
24
  gemspec.email = "timon.karnezos@gmail.com"
25
25
  gemspec.homepage = "http://github.com/timonk/global_collect"
26
26
  gemspec.authors = ["Timon Karnezos"]
27
- gemspec.version = "0.1.1"
27
+ gemspec.version = "0.1.2"
28
28
  gemspec.add_dependency('httparty', '>= 0.5.2')
29
29
  gemspec.add_dependency('builder', '>= 2.0')
30
30
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.1.2
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require File.join(File.dirname(__FILE__), '..', "lib", "global_collect")
3
+
4
+
5
+ require File.join(File.dirname(__FILE__), '..', "spec", "support", "support_helper")
6
+ env = :test
7
+ auth = :ip_check
8
+ install_canned_response(:merchant_link, env, auth, :successful, :get_order_status, :v2)
9
+
10
+ GlobalCollect.merchant_id = ""
11
+ GlobalCollect.authentication_scheme = auth
12
+ GlobalCollect.environment = env
13
+ GlobalCollect.ip_address = ""
14
+ #GlobalCollect.wire_log_file = File.join(File.dirname(__FILE__), "gc.log")
15
+
16
+ client = GlobalCollect.merchant_link_client
17
+
18
+ req = GlobalCollect::Requests::GetOrderStatus.new("53")
19
+ req.version = "1.0"
20
+ response = client.make_request(req)
21
+ p response.request_id == "350556"
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{global_collect}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Timon Karnezos"]
12
- s.date = %q{2010-04-28}
12
+ s.date = %q{2010-04-30}
13
13
  s.description = %q{Gives minimally intrusive access to Global Collect's payment processing API.
14
14
  Currently implements a very small segment of the full API but is built with
15
15
  extensibility in mind.
@@ -19,7 +19,8 @@ extensibility in mind.
19
19
  "README.markdown"
20
20
  ]
21
21
  s.files = [
22
- "COPYING",
22
+ ".gitignore",
23
+ "COPYING",
23
24
  "HISTORY",
24
25
  "README.markdown",
25
26
  "Rakefile",
@@ -30,6 +31,7 @@ extensibility in mind.
30
31
  "examples/insert_order_with_payment.rb",
31
32
  "examples/process_challenged.rb",
32
33
  "examples/set_payment.rb",
34
+ "examples/support_helper_ex.rb",
33
35
  "examples/test_connection.rb",
34
36
  "global_collect.gemspec",
35
37
  "lib/global_collect.rb",
@@ -100,17 +102,18 @@ extensibility in mind.
100
102
  "spec/responses/insert_order_with_payment/hosted_merchant_link_payment_response_methods_spec.rb",
101
103
  "spec/responses/succcess_row_spec.rb",
102
104
  "spec/spec_helper.rb",
103
- "spec/support/challenged_iowp_response.xml",
104
- "spec/support/successful_convert_amount_response.xml",
105
- "spec/support/successful_do_refund_response.xml",
105
+ "spec/support/challenged_iowp_v1_response.xml",
106
+ "spec/support/successful_convert_amount_v1_response.xml",
107
+ "spec/support/successful_do_refund_v1_response.xml",
106
108
  "spec/support/successful_get_order_status_v1_response.xml",
107
109
  "spec/support/successful_get_order_status_v2_response.xml",
108
- "spec/support/successful_hosted_iowp_response.xml",
109
- "spec/support/successful_iowp_response.xml",
110
+ "spec/support/successful_hosted_iowp_v1_response.xml",
111
+ "spec/support/successful_iowp_v1_response.xml",
110
112
  "spec/support/successful_process_challenged_response.xml",
111
- "spec/support/unsuccessful_do_refund_response.xml",
112
- "spec/support/unsuccessful_iowp_response.xml",
113
- "spec/support/unsuccessful_process_challenged_response.xml"
113
+ "spec/support/support_helper.rb",
114
+ "spec/support/unsuccessful_do_refund_v1_response.xml",
115
+ "spec/support/unsuccessful_iowp_v1_response.xml",
116
+ "spec/support/unsuccessful_process_challenged_v1_response.xml"
114
117
  ]
115
118
  s.homepage = %q{http://github.com/timonk/global_collect}
116
119
  s.rdoc_options = ["--charset=UTF-8"]
@@ -147,12 +150,14 @@ extensibility in mind.
147
150
  "spec/responses/insert_order_with_payment/hosted_merchant_link_payment_response_methods_spec.rb",
148
151
  "spec/responses/succcess_row_spec.rb",
149
152
  "spec/spec_helper.rb",
153
+ "spec/support/support_helper.rb",
150
154
  "examples/cancel_payment.rb",
151
155
  "examples/convert_amount.rb",
152
156
  "examples/get_order_status.rb",
153
157
  "examples/insert_order_with_payment.rb",
154
158
  "examples/process_challenged.rb",
155
159
  "examples/set_payment.rb",
160
+ "examples/support_helper_ex.rb",
156
161
  "examples/test_connection.rb"
157
162
  ]
158
163
 
@@ -45,8 +45,6 @@ module GlobalCollect
45
45
  base
46
46
  end
47
47
 
48
- private
49
-
50
48
  def self.service_url(service, environment, authentication)
51
49
  # WDL §§3.4-5 specify the allowed arguments
52
50
  raise ArgumentError.new("Only [Hosted] Merchant Link is currently supported!") unless [:merchant_link].include?(service)
@@ -22,7 +22,7 @@ describe 'the api client' do
22
22
  end
23
23
 
24
24
  it "should post to the correct url" do
25
- FakeWeb.register_uri(:post, "https://ps.gcsip.nl/wdl/wdl", :body => read_canned_response('successful_iowp_response.xml'))
25
+ wire_up_response(:successful, :iowp, :v1)
26
26
  client = GlobalCollect::ApiClient.new(:merchant_link, :test, :ip_check)
27
27
 
28
28
  request = mock(
@@ -36,7 +36,7 @@ describe 'the api client' do
36
36
  end
37
37
 
38
38
  it "should mix in the proper mixins to the response by default" do
39
- FakeWeb.register_uri(:post, "https://ps.gcsip.nl/wdl/wdl", :body => read_canned_response('successful_iowp_response.xml'))
39
+ wire_up_response(:successful, :iowp, :v1)
40
40
  client = GlobalCollect::ApiClient.new(:merchant_link, :test, :ip_check)
41
41
 
42
42
  request = mock(
@@ -50,7 +50,7 @@ describe 'the api client' do
50
50
  end
51
51
 
52
52
  it "should not mix in anything if directed not to" do
53
- FakeWeb.register_uri(:post, "https://ps.gcsip.nl/wdl/wdl", :body => read_canned_response('successful_iowp_response.xml'))
53
+ wire_up_response(:successful, :iowp, :v1)
54
54
  client = GlobalCollect::ApiClient.new(:merchant_link, :test, :ip_check)
55
55
 
56
56
  request = mock(
@@ -64,7 +64,7 @@ describe 'the api client' do
64
64
  end
65
65
 
66
66
  it "should error on no response" do
67
- FakeWeb.register_uri(:post, "https://ps.gcsip.nl/wdl/wdl", :body => read_canned_response('successful_iowp_response.xml'))
67
+ wire_up_response(:successful, :iowp, :v1)
68
68
  client = GlobalCollect::ApiClient.new(:merchant_link, :test, :ip_check)
69
69
  client.class.should_receive(:post).and_return(nil)
70
70
  request = mock(
@@ -77,7 +77,7 @@ describe 'the api client' do
77
77
  end
78
78
 
79
79
  it "should error on a malformed response" do
80
- FakeWeb.register_uri(:post, "https://ps.gcsip.nl/wdl/wdl", :body => read_canned_response('successful_iowp_response.xml'))
80
+ wire_up_response(:successful, :iowp, :v1)
81
81
  client = GlobalCollect::ApiClient.new(:merchant_link, :test, :ip_check)
82
82
  response = mock(:response, :body => "Foo bar", :code => "200", :delegate => {})
83
83
  client.class.should_receive(:post).and_return(response)
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
3
3
  describe "the base response" do
4
4
  describe "on a successful response" do
5
5
  before(:each) do
6
- @response = load_canned_response('successful_iowp_response.xml')
6
+ @response = parse_canned_response(:successful, :iowp, :v1)
7
7
  end
8
8
 
9
9
  it "should identify success" do
@@ -32,7 +32,7 @@ describe "the base response" do
32
32
 
33
33
  describe "on an unsuccessful response" do
34
34
  before(:each) do
35
- @response = load_canned_response('unsuccessful_iowp_response.xml')
35
+ @response = parse_canned_response(:unsuccessful, :iowp, :v1)
36
36
  end
37
37
 
38
38
  it "should identify success" do
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
2
 
3
3
  describe "the convert amount response methods" do
4
4
  before(:each) do
5
- @response = load_canned_response('successful_convert_amount_response.xml')
5
+ @response = parse_canned_response(:successful, :convert_amount, :v1)
6
6
  @response.extend(GlobalCollect::Responses::SuccessRow)
7
7
  @response.extend(GlobalCollect::Responses::ConvertAmount::ResponseMethods)
8
8
  end
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
2
 
3
3
  describe "the do refund response methods" do
4
4
  before(:each) do
5
- @response = load_canned_response('successful_do_refund_response.xml')
5
+ @response = parse_canned_response(:successful, :do_refund, :v1)
6
6
  @response.extend(GlobalCollect::Responses::SuccessRow)
7
7
  @response.extend(GlobalCollect::Responses::DoRefund::ResponseMethods)
8
8
  end
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
2
 
3
3
  describe "the v1 get order status response methods" do
4
4
  before(:each) do
5
- @response = load_canned_response('successful_get_order_status_v1_response.xml')
5
+ @response = parse_canned_response(:successful, :get_order_status, :v1)
6
6
  @response.extend(GlobalCollect::Responses::GetOrderStatus::V1ResponseMethods)
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
2
 
3
3
  describe "the v2 get order status response methods" do
4
4
  before(:each) do
5
- @response = load_canned_response('successful_get_order_status_v2_response.xml')
5
+ @response = parse_canned_response(:successful, :get_order_status, :v2)
6
6
  @response.extend(GlobalCollect::Responses::GetOrderStatus::V2ResponseMethods)
7
7
  end
8
8
 
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
2
 
3
3
  describe "the credit card online payment response methods" do
4
4
  before(:each) do
5
- @response = load_canned_response('successful_iowp_response.xml')
5
+ @response = parse_canned_response(:successful, :iowp, :v1)
6
6
  @response.extend(GlobalCollect::Responses::SuccessRow)
7
7
  @response.extend(GlobalCollect::Responses::InsertOrderWithPayment::CreditCardOnlinePaymentResponseMethods)
8
8
  end
@@ -2,7 +2,7 @@ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
2
 
3
3
  describe "the hosted merchant link payment response methods" do
4
4
  before(:each) do
5
- @response = load_canned_response('successful_hosted_iowp_response.xml')
5
+ @response = parse_canned_response(:successful, :hosted_iowp, :v1)
6
6
  @response.extend(GlobalCollect::Responses::SuccessRow)
7
7
  @response.extend(GlobalCollect::Responses::InsertOrderWithPayment::HostedMerchantLinkPaymentResponseMethods)
8
8
  end
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
3
3
  describe "the base response" do
4
4
  describe "on a successful response" do
5
5
  before(:each) do
6
- @response = load_canned_response('successful_iowp_response.xml')
6
+ @response = parse_canned_response(:successful, :iowp, :v1)
7
7
  end
8
8
 
9
9
  it "should provide the success data hash" do
@@ -15,7 +15,7 @@ describe "the base response" do
15
15
 
16
16
  describe "on an unsuccessful response" do
17
17
  before(:each) do
18
- @response = load_canned_response('unsuccessful_iowp_response.xml')
18
+ @response = parse_canned_response(:unsuccessful, :iowp, :v1)
19
19
  end
20
20
 
21
21
  it "should not provide the success data hash" do
data/spec/spec_helper.rb CHANGED
@@ -5,21 +5,15 @@ require 'global_collect'
5
5
  # initialiaze the logger and silence it for the tests
6
6
  GlobalCollect.wire_logger.level = 4
7
7
 
8
- require 'fakeweb'
9
- FakeWeb.allow_net_connect = false
10
-
11
- def read_canned_response(filename)
12
- File.read(File.join(File.dirname(__FILE__), "support", filename))
13
- end
8
+ require File.join(File.dirname(__FILE__), "support", "support_helper")
14
9
 
15
- def load_canned_response(filename)
16
- contents = read_canned_response(filename)
17
- GlobalCollect::Responses::Base.new(Crack::XML.parse(contents), contents)
10
+ FakeWeb.allow_net_connect = false
11
+ def wire_up_response(success, action, version)
12
+ install_canned_response(:merchant_link, :test, :ip_check, success, action, version)
18
13
  end
19
14
 
20
15
  require 'crack'
21
16
 
22
-
23
17
  require 'rexml/document'
24
18
  require 'rexml/element'
25
19
 
@@ -0,0 +1,25 @@
1
+ require 'fakeweb'
2
+
3
+ def read_canned_response(filename)
4
+ File.read(File.join(File.dirname(__FILE__), filename))
5
+ end
6
+
7
+ def filename_for(success, action, version)
8
+ filename = [
9
+ success,
10
+ action,
11
+ version,
12
+ "response"
13
+ ].map(&:to_s).join("_") + ".xml"
14
+ end
15
+
16
+ def install_canned_response(service, env, auth_scheme, success, action, version)
17
+ response_body = read_canned_response(filename_for(success, action, version))
18
+ service_url = GlobalCollect::ApiClient.service_url(service, env, auth_scheme)
19
+ FakeWeb.register_uri(:post, service_url, :body => response_body)
20
+ end
21
+
22
+ def parse_canned_response(success, action, version)
23
+ response_body = read_canned_response(filename_for(success, action, version))
24
+ GlobalCollect::Responses::Base.new(Crack::XML.parse(response_body), response_body)
25
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Timon Karnezos
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-28 00:00:00 -07:00
17
+ date: 2010-04-30 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -71,6 +71,7 @@ extensions: []
71
71
  extra_rdoc_files:
72
72
  - README.markdown
73
73
  files:
74
+ - .gitignore
74
75
  - COPYING
75
76
  - HISTORY
76
77
  - README.markdown
@@ -82,6 +83,7 @@ files:
82
83
  - examples/insert_order_with_payment.rb
83
84
  - examples/process_challenged.rb
84
85
  - examples/set_payment.rb
86
+ - examples/support_helper_ex.rb
85
87
  - examples/test_connection.rb
86
88
  - global_collect.gemspec
87
89
  - lib/global_collect.rb
@@ -152,17 +154,18 @@ files:
152
154
  - spec/responses/insert_order_with_payment/hosted_merchant_link_payment_response_methods_spec.rb
153
155
  - spec/responses/succcess_row_spec.rb
154
156
  - spec/spec_helper.rb
155
- - spec/support/challenged_iowp_response.xml
156
- - spec/support/successful_convert_amount_response.xml
157
- - spec/support/successful_do_refund_response.xml
157
+ - spec/support/challenged_iowp_v1_response.xml
158
+ - spec/support/successful_convert_amount_v1_response.xml
159
+ - spec/support/successful_do_refund_v1_response.xml
158
160
  - spec/support/successful_get_order_status_v1_response.xml
159
161
  - spec/support/successful_get_order_status_v2_response.xml
160
- - spec/support/successful_hosted_iowp_response.xml
161
- - spec/support/successful_iowp_response.xml
162
+ - spec/support/successful_hosted_iowp_v1_response.xml
163
+ - spec/support/successful_iowp_v1_response.xml
162
164
  - spec/support/successful_process_challenged_response.xml
163
- - spec/support/unsuccessful_do_refund_response.xml
164
- - spec/support/unsuccessful_iowp_response.xml
165
- - spec/support/unsuccessful_process_challenged_response.xml
165
+ - spec/support/support_helper.rb
166
+ - spec/support/unsuccessful_do_refund_v1_response.xml
167
+ - spec/support/unsuccessful_iowp_v1_response.xml
168
+ - spec/support/unsuccessful_process_challenged_v1_response.xml
166
169
  has_rdoc: true
167
170
  homepage: http://github.com/timonk/global_collect
168
171
  licenses: []
@@ -223,10 +226,12 @@ test_files:
223
226
  - spec/responses/insert_order_with_payment/hosted_merchant_link_payment_response_methods_spec.rb
224
227
  - spec/responses/succcess_row_spec.rb
225
228
  - spec/spec_helper.rb
229
+ - spec/support/support_helper.rb
226
230
  - examples/cancel_payment.rb
227
231
  - examples/convert_amount.rb
228
232
  - examples/get_order_status.rb
229
233
  - examples/insert_order_with_payment.rb
230
234
  - examples/process_challenged.rb
231
235
  - examples/set_payment.rb
236
+ - examples/support_helper_ex.rb
232
237
  - examples/test_connection.rb