debitech_soap 1.1.0 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 612d31c258c331bf8992dc12ad8e1985b71d6632
4
- data.tar.gz: cc3de7baad1153bc602b514e35cfbe27647a8a5e
3
+ metadata.gz: 27d41ad832b2eba41d08b3aa17b750a104fe92d9
4
+ data.tar.gz: e55ad817106d4bf04ffd0c84b9a3926aebc9119f
5
5
  SHA512:
6
- metadata.gz: 0be2a047692d1fd006f5fda7e1cf00ed667169834c0149e1f32bb8edd0efbc036ab0fa3f8bdf6e63bed984cb74ce4421e1e30b8a9c41b274acdf4936f0d68774
7
- data.tar.gz: dfd24f8a6b2f5e514dd2edc799e8795d26c0d560360658631d6cdad2d25ec7328fa160f46b3346e3d60eddf0319faeeca405f296077c6d46f333336a540be076
6
+ metadata.gz: 6e05d146e4c3f7ded0a9fc6fe19edfa3ce6c838368db5b1b58cca9b1600cec63d3510440f9064bfacdbb8d75d947ff4622ef0c805da924c82b53cec570f4b991
7
+ data.tar.gz: fcf23bc8f637d58d2d42bbd17c7f43576d462b5c888a3cf54beab2e92f6e91c5f2b4496526d56d6f3792cb829c1d44f976db7703fb9e94fccde2d97c1772065b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- debitech_soap (1.0.3)
4
+ debitech_soap (1.1.1)
5
5
  httpclient (>= 2.4.0)
6
6
  mumboe-soap4r (~> 1.5.8.4)
7
7
 
@@ -13,7 +13,7 @@ GEM
13
13
  thor (~> 0.14.6)
14
14
  guard-rspec (0.5.0)
15
15
  guard (>= 0.8.4)
16
- httpclient (2.4.0)
16
+ httpclient (2.8.3)
17
17
  mumboe-soap4r (1.5.8.7)
18
18
  httpclient (>= 2.1.1)
19
19
  rake (0.9.2)
@@ -36,3 +36,6 @@ DEPENDENCIES
36
36
  guard-rspec
37
37
  rake
38
38
  rspec
39
+
40
+ BUNDLED WITH
41
+ 1.15.4
@@ -40,6 +40,9 @@ module DebitechSoap
40
40
  @client = SOAP::WSDLDriverFactory.new(File.join(File.dirname(__FILE__), "../service.wsdl")).create_rpc_driver
41
41
  end
42
42
 
43
+ # Uncomment this line if you want to see the request and response printed to STDERR.
44
+ #@client.wiredump_dev = STDERR
45
+
43
46
  # Enable changing supported ciphers, for deprecation situations like http://tech.dibspayment.com/nodeaddpage/listofapprovedciphersuites.
44
47
  # This lets us easily experiment in development, and to do quick changes in production if we must.
45
48
  dibs_httpclient_ciphers = ENV["DIBS_HTTPCLIENT_CIPHERS"]
@@ -53,7 +56,21 @@ module DebitechSoap
53
56
 
54
57
  def valid_credentials?
55
58
  disable_stderr do
56
- return_value(@client.checkSwedishPersNo(@api_credentials.merge({ :persNo => "5555555555" }))) == "true"
59
+ # We make a "refund" request, but we make sure to set the amount to 0 and to enter a verify ID that will never match a real one.
60
+ # Previously, we'd confirm credentials with the safer checkSwedishPersNo call, but that seems broken now (always returns false).
61
+ response_value = return_value(@client.refund(@api_credentials.merge({ :verifyID => -1, :amount => 0 })))
62
+ result_text = response_value.resultText
63
+
64
+ case result_text
65
+ when "error_transID_or_verifyID"
66
+ # The auth succeeded, but the refund (thankfully and intentionally) did not.
67
+ true
68
+ when "336 web_service_login_failed"
69
+ # The auth is wrong.
70
+ false
71
+ else
72
+ raise "Unexpected result text: #{result_text.inspect}"
73
+ end
57
74
  end
58
75
  end
59
76
 
@@ -1,3 +1,3 @@
1
1
  module DebitechSoap
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -35,23 +35,29 @@ describe DebitechSoap::API, "valid_credentials?" do
35
35
  SOAP::WSDLDriverFactory.stub!(:new).and_return(mock(Object, :create_rpc_driver => @client))
36
36
  end
37
37
 
38
- it "should call checkSwedishPersNo with the credentials and a valid swedish social security number" do
39
- @client.should_receive(:checkSwedishPersNo).with(:shopName => "merchant_name", :userName => "api_user_name",
40
- :password => "api_user_password", :persNo => "5555555555").
41
- and_return(mock(Object, :return => "true"))
38
+ it "should call 'refund' with the credentials and dummy values, returning true if we were authed but failed to refund" do
39
+ @client.should_receive(:refund).with(:shopName => "merchant_name", :userName => "api_user_name",
40
+ :password => "api_user_password", :verifyID => -1, :amount => 0).
41
+ and_return(mock(Object, :return => mock(Object, :resultText => "error_transID_or_verifyID")))
42
42
 
43
43
  api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
44
44
  api.valid_credentials?.should == true
45
45
  end
46
46
 
47
- it "should return false if the service returns false" do
48
- @client.stub!(:checkSwedishPersNo).and_return(mock(Object, :return => "false"))
47
+ it "should return false if the service returns an auth error" do
48
+ @client.stub!(:refund).and_return(mock(Object, :return => mock(Object, :resultText => "336 web_service_login_failed")))
49
49
  api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
50
50
  api.valid_credentials?.should == false
51
51
  end
52
52
 
53
+ it "raises if the service returns an unexpected result" do
54
+ @client.stub!(:refund).and_return(mock(Object, :return => mock(Object, :resultText => "let's have lunch")))
55
+ api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
56
+ expect { api.valid_credentials? }.to raise_error(%{Unexpected result text: "let's have lunch"})
57
+ end
58
+
53
59
  it "should work with Ruby 1.9 SOAP API" do
54
- @client.stub!(:checkSwedishPersNo).and_return(mock(Object, :m_return => "true"))
60
+ @client.stub!(:refund).and_return(mock(Object, :m_return => mock(Object, :resultText => "error_transID_or_verifyID")))
55
61
  api = DebitechSoap::API.new
56
62
  api.valid_credentials?.should == true
57
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debitech_soap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Kolsjö
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-02-15 00:00:00.000000000 Z
14
+ date: 2017-12-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: httpclient
@@ -143,8 +143,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  requirements: []
145
145
  rubyforge_project:
146
- rubygems_version: 2.6.8
146
+ rubygems_version: 2.6.11
147
147
  signing_key:
148
148
  specification_version: 4
149
149
  summary: A pure ruby way to make payments with DebiTech
150
- test_files: []
150
+ test_files:
151
+ - spec/debitech_soap_spec.rb