debitech_soap 1.0.2 → 1.2.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bd72f376fc8244561d542048c01a2a67f3c6af855b7f5d1f48e79d334935f62c
4
+ data.tar.gz: 58f219906628833960645ee107abed6384bccc57816a56bb7b5d3521b120fbaa
5
+ SHA512:
6
+ metadata.gz: bf50187ec7a834e00c8260eabe716cefb8291236f357c7c41104afe837961dd37cfb7f1bdb7befa15aba54200ea6bab45175d243722b18de77c0762d2322f17e
7
+ data.tar.gz: 0f510554dd1452104ff04df0215a779bb1e9100e3e03a93247368c92b24453af067c7257c47a13844e5eb70044018e1ddbbde3dcdd3d26bc08c31f8c858eb169
@@ -0,0 +1,26 @@
1
+ name: Ruby CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ["3.0", "2.7", "2.6", "2.5"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby ${{ matrix.ruby-version }}
21
+ uses: ruby/setup-ruby@ae9cb3b565e36682a2c6045e4f664388da4c73aa
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25
+ - name: Run tests
26
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -7,3 +7,6 @@ todo.txt
7
7
  */**/.*.swp
8
8
  */**/*.swp
9
9
  */*/*/*.swp
10
+ tmp
11
+ Gemfile.lock
12
+ *.gem
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ AllCops:
2
+ Exclude:
3
+ - "tmp/**/*"
4
+ inherit_gem:
5
+ barsoom_utils: shared_rubocop.yml
data/Gemfile CHANGED
@@ -2,3 +2,12 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in debitech_soap.gemspec
4
4
  gemspec
5
+
6
+ group :development, :test do
7
+ gem "barsoom_utils", github: "barsoom/barsoom_utils"
8
+ gem "guard"
9
+ gem "guard-rspec"
10
+ gem "rake"
11
+ gem "rspec"
12
+ gem "rubocop"
13
+ end
data/Guardfile CHANGED
@@ -1,4 +1,4 @@
1
- guard 'rspec', :version => 2, :cli => "--color" do
1
+ guard "rspec", :version => 2, :cli => "--color" do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
3
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec" }
4
4
  end
data/README.markdown CHANGED
@@ -1,5 +1,4 @@
1
- [![Build Status](https://secure.travis-ci.org/joakimk/debitech_soap.png)](http://travis-ci.org/joakimk/debitech_soap)
2
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/joakimk/debitech_soap)
1
+ [![Ruby CI](https://github.com/barsoom/debitech_soap/actions/workflows/ci.yml/badge.svg)](https://github.com/barsoom/debitech_soap/actions/workflows/ci.yml)
3
2
 
4
3
  This is a wrapper of the DebiTech SOAP API. It's intended to be API compatible with the DebiTech Java client but also supports a more developer friendly syntax :).
5
4
 
@@ -7,33 +6,33 @@ If you're looking for a more complete solution, check the [debitech](https://git
7
6
 
8
7
  Installing
9
8
  ----
10
-
11
- gem install debitech_soap
12
-
9
+ ```bash
10
+ gem install debitech_soap
11
+ ```
13
12
  Usage
14
13
  ----
15
14
 
16
15
  This is how you would have used the DebiTech Java API:
17
-
18
- include_class "com.verifyeasy.server.VEServer"
19
- veserver = VEServer.get_instance("https://secure.incab.se/verify/server/merchant_name")
20
-
16
+ ```java
17
+ include_class "com.verifyeasy.server.VEServer"
18
+ veserver = VEServer.get_instance("https://secure.incab.se/verify/server/merchant_name")
19
+ ```
21
20
  This is how you use DebitechSoap:
22
-
23
- require 'debitech_soap'
24
- veserver = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
25
-
21
+ ```ruby
22
+ require 'debitech_soap'
23
+ veserver = DebitechSoap::API.new(merchant: "merchant_name", username: "api_user_name", password: "api_user_password")
24
+ ```
26
25
  Supported arguments
27
26
  ----
28
27
 
29
28
  Java style (see DebitechSoap::API::PARAMS.keys in lib/debitech_soap.rb):
30
-
31
- veserver.refund(1234567, 23456, 100, "extra")
32
-
29
+ ```java
30
+ veserver.refund(1234567, 23456, 100, "extra")
31
+ ```
33
32
  Hash:
34
-
35
- veserver.refund(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra")
36
-
33
+ ```ruby
34
+ veserver.refund(verifyID: 1234567, transID: 23456, amount: 100, extra: "extra")
35
+ ```
37
36
  Custom methods
38
37
  ----
39
38
 
@@ -56,3 +55,16 @@ API docs
56
55
  ----
57
56
 
58
57
  Get DIBSServerManual.pdf from the DIBS Manager.
58
+
59
+ Changing HTTPClient SSL ciphers
60
+ ----
61
+
62
+ If you're a library developer, you may want to experiment with changing the set of HTTPClient SSL ciphers, e.g. if DIBS deprecates old ones.
63
+
64
+ You can do that by setting an environment variable:
65
+
66
+ DIBS_HTTPCLIENT_CIPHERS='ALL:!aNULL:!eNULL:!SSLv2'
67
+
68
+ If nothing is set, it uses the default (`HTTPClient::SSLConfig::CIPHERS_DEFAULT`).
69
+
70
+ Once the experiments are concluded, you should move that configuration into the library instead, so each user of this library doesn't have to configure it.
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
- require 'bundler'
2
- require 'rspec/core/rake_task'
1
+ require "bundler"
2
+ require "rspec/core/rake_task"
3
3
 
4
4
  Bundler::GemHelper.install_tasks
5
5
 
6
6
  desc "Run all specs"
7
- RSpec::Core::RakeTask.new('spec') do |t|
8
- t.pattern = 'spec/**/*.rb'
7
+ RSpec::Core::RakeTask.new("spec") do |t|
8
+ t.pattern = "spec/**/*.rb"
9
9
  end
10
10
 
11
11
  task :default => :spec
@@ -6,21 +6,22 @@ Gem::Specification.new do |s|
6
6
  s.name = "debitech_soap"
7
7
  s.version = DebitechSoap::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Joakim Kolsjö", 'Niklas Holmgren', 'Henrik Nyh', 'Daniel Eriksson']
10
- s.email = ["joakim.kolsjo@gmail.com", 'niklas.holmgren@bukowskis.com', 'henrik@barsoom.se']
11
- s.homepage = "http://github.com/joakimk/debitech_soap"
9
+ s.authors = [ "Joakim Kolsjö", "Niklas Holmgren", "Henrik Nyh", "Daniel Eriksson" ]
10
+ s.email = [ "joakim.kolsjo@gmail.com", "niklas.holmgren@bukowskis.com", "henrik@barsoom.se" ]
11
+ s.homepage = "http://github.com/barsoom/debitech_soap"
12
12
  s.summary = %q{A pure ruby way to make payments with DebiTech}
13
13
  s.description = %q{An implementation of the DebiTech Java API using pure ruby and the SOAP API.}
14
+ s.metadata = { "rubygems_mfa_required" => "true" }
14
15
 
15
- s.add_dependency "mumboe-soap4r", "~> 1.5.8.4"
16
+ # Earlier versions of HTTPClient may prefer SSLv3 as its ssl_version,
17
+ # but 2014-10-15 Debitech started having issues with SSLv3, sometimes returning
18
+ # "sslv3 alert handshake failure"
19
+ # Probably because of changes to counter the "Poodle" vulnerability.
20
+ # See: https://gist.github.com/henrik/321bb53dc7c236a6f4a0
21
+ s.add_dependency "httpclient", ">= 2.4.0"
16
22
 
17
- s.add_development_dependency "rake"
18
- s.add_development_dependency 'rspec'
19
- s.add_development_dependency "guard"
20
- s.add_development_dependency "guard-rspec"
23
+ s.add_dependency "mumboe-soap4r", "~> 1.5.8.4"
21
24
 
22
25
  s.files = `git ls-files`.split("\n")
23
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
24
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
25
- s.require_paths = ["lib"]
26
+ s.require_paths = [ "lib" ]
26
27
  end
@@ -1,34 +1,28 @@
1
- require 'stringio'
1
+ require "stringio"
2
2
  $previous_stderr = $stderr
3
3
  $stderr = StringIO.new
4
- require 'soap/wsdlDriver'
4
+ require "soap/wsdlDriver"
5
5
  $stderr = $previous_stderr
6
- require 'ostruct'
7
- require 'debitech_soap/string_extensions'
6
+ require "ostruct"
7
+ require "debitech_soap/string_extensions"
8
8
 
9
9
  module DebitechSoap
10
10
  class API
11
11
 
12
12
  RETURN_DATA = %w{aCSUrl acquirerAddress acquirerAuthCode acquirerAuthResponseCode acquirerCity acquirerConsumerLimit acquirerErrorDescription acquirerFirstName acquirerLastName acquirerMerchantLimit acquirerZipCode amount errorMsg infoCode infoDescription pAReqMsg resultCode resultText verifyID}
13
13
 
14
- PARAMS = { %w(settle) => ["verifyID", "transID", "amount", "extra"],
15
- %w(subscribeAndSettle subscribe_and_settle) \
16
- => ["verifyID", "transID", "data", "ip", "extra"],
17
- %w(authorize) => ["billingFirstName", "billingLastName", "billingAddress", "billingCity",
18
- "billingCountry", "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID", "extra"],
19
- %w(authorizeAndSettle3DS authorize_and_settle_3ds) \
20
- => ["verifyID", "paRes", "extra"],
21
- %w(refund) => ["verifyID", "transID", "amount", "extra"],
22
- %w(askIf3DSEnrolled ask_if_3ds_enrolled) \
23
- => ["billingFirstName", "billingLastName", "billingAddress", "billingCity",
24
- "billingCountry", "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID",
25
- "httpAcceptHeader", "httpUserAgentHeader", "method", "referenceNo", "extra"],
26
- %w(authReversal auth_reversal) => ["verifyID", "amount", "transID", "extra"],
27
- %w(authorize3DS authorize_3ds) => ["verifyID", "paRes", "extra"],
28
- %w(subscribe) => ["verifyID", "transID", "data", "ip", "extra"],
29
- %w(authorizeAndSettle authorize_and_settle) \
30
- => ["billingFirstName", "billingLastName", "billingAddress", "billingCity", "billingCountry",
31
- "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID", "extra"] }
14
+ PARAMS = {
15
+ %w(settle) => [ "verifyID", "transID", "amount", "extra" ],
16
+ %w(subscribeAndSettle subscribe_and_settle) => [ "verifyID", "transID", "data", "ip", "extra" ],
17
+ %w(authorize) => [ "billingFirstName", "billingLastName", "billingAddress", "billingCity", "billingCountry", "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID", "extra" ],
18
+ %w(authorizeAndSettle3DS authorize_and_settle_3ds) => [ "verifyID", "paRes", "extra" ],
19
+ %w(refund) => [ "verifyID", "transID", "amount", "extra" ],
20
+ %w(askIf3DSEnrolled ask_if_3ds_enrolled) => [ "billingFirstName", "billingLastName", "billingAddress", "billingCity", "billingCountry", "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID", "httpAcceptHeader", "httpUserAgentHeader", "method", "referenceNo", "extra" ],
21
+ %w(authReversal auth_reversal) => [ "verifyID", "amount", "transID", "extra" ],
22
+ %w(authorize3DS authorize_3ds) => [ "verifyID", "paRes", "extra" ],
23
+ %w(subscribe) => [ "verifyID", "transID", "data", "ip", "extra" ],
24
+ %w(authorizeAndSettle authorize_and_settle) => [ "billingFirstName", "billingLastName", "billingAddress", "billingCity", "billingCountry", "cc", "expM", "expY", "eMail", "ip", "data", "currency", "transID", "extra" ],
25
+ }
32
26
 
33
27
  def initialize(opts = {})
34
28
  @api_credentials = {}
@@ -40,12 +34,37 @@ module DebitechSoap
40
34
  @client = SOAP::WSDLDriverFactory.new(File.join(File.dirname(__FILE__), "../service.wsdl")).create_rpc_driver
41
35
  end
42
36
 
37
+ # Uncomment this line if you want to see the request and response printed to STDERR.
38
+ #@client.wiredump_dev = STDERR
39
+
40
+ # Enable changing supported ciphers, for deprecation situations like http://tech.dibspayment.com/nodeaddpage/listofapprovedciphersuites.
41
+ # This lets us easily experiment in development, and to do quick changes in production if we must.
42
+ dibs_httpclient_ciphers = ENV["DIBS_HTTPCLIENT_CIPHERS"]
43
+ if dibs_httpclient_ciphers
44
+ httpclient_instance = @client.streamhandler.client
45
+ httpclient_instance.ssl_config.ciphers = dibs_httpclient_ciphers
46
+ end
47
+
43
48
  define_java_wrapper_methods!
44
49
  end
45
50
 
46
51
  def valid_credentials?
47
52
  disable_stderr do
48
- return_value(@client.checkSwedishPersNo(@api_credentials.merge({ :persNo => "5555555555" }))) == "true"
53
+ # 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.
54
+ # Previously, we'd confirm credentials with the safer checkSwedishPersNo call, but that seems broken now (always returns false).
55
+ response_value = return_value(@client.refund(@api_credentials.merge({ verifyID: -1, amount: 0 })))
56
+ result_text = response_value.resultText
57
+
58
+ case result_text
59
+ when "error_transID_or_verifyID"
60
+ # The auth succeeded, but the refund (thankfully and intentionally) did not.
61
+ true
62
+ when "336 web_service_login_failed"
63
+ # The auth is wrong.
64
+ false
65
+ else
66
+ raise "Unexpected result text: #{result_text.inspect}"
67
+ end
49
68
  end
50
69
  end
51
70
 
@@ -64,18 +83,18 @@ module DebitechSoap
64
83
  define_method(method) do |*args| # def refund(*args)
65
84
  attributes = @api_credentials.clone
66
85
 
67
- if args.first.is_a?(Hash)
86
+ if args.first.is_a?(Hash)
68
87
  attributes.merge!(args.first)
69
88
  else
70
89
  parameter_order = api_signature(method).last
71
90
  args.each_with_index { |argument, i|
72
91
  attributes[parameter_order[i].to_sym] = argument
73
92
  }
74
- end
93
+ end
75
94
  begin
76
95
  client_result = return_value(@client.send(api_signature(method).first.first, attributes))
77
96
  rescue Timeout::Error
78
- client_result = OpenStruct.new(:resultCode => 403, :resultText => "SOAP Timeout")
97
+ client_result = OpenStruct.new(resultCode: 403, resultText: "SOAP Timeout")
79
98
  return return_data(client_result)
80
99
  end
81
100
  return_data(client_result)
@@ -105,16 +124,14 @@ module DebitechSoap
105
124
  end
106
125
 
107
126
  def disable_stderr
108
- begin
109
- $stderr = File.open('/dev/null', 'w')
110
- yield
111
- ensure
112
- $stderr = STDERR
113
- end
127
+ $stderr = File.open("/dev/null", "w")
128
+ yield
129
+ ensure
130
+ $stderr = STDERR
114
131
  end
115
132
 
116
133
  def api_signature(method)
117
- PARAMS.find {|key,value| key.include?(method.to_s) }
134
+ PARAMS.find { |key, value| key.include?(method.to_s) }
118
135
  end
119
136
 
120
137
  end
@@ -4,9 +4,9 @@ module DebitechSoap
4
4
  module Underscore
5
5
  def underscore
6
6
  word = dup
7
- word.gsub!(/::/, '/')
8
- word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
9
- word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
7
+ word.gsub!(/::/, "/")
8
+ word.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
9
+ word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
10
10
  word.tr!("-", "_")
11
11
  word.downcase!
12
12
  word
@@ -26,13 +26,13 @@ module DebitechSoap
26
26
  end
27
27
  end
28
28
 
29
- unless String.methods.include?('underscore')
29
+ unless String.methods.include?("underscore")
30
30
  String.class_eval do
31
31
  include DebitechSoap::StringExtensions::Underscore
32
32
  end
33
33
  end
34
34
 
35
- unless String.methods.include?('camelcase')
35
+ unless String.methods.include?("camelcase")
36
36
  String.class_eval do
37
37
  include DebitechSoap::StringExtensions::CamelCase
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module DebitechSoap
2
- VERSION = "1.0.2"
2
+ VERSION = "1.2.1"
3
3
  end
data/lib/debitech_soap.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module DebitechSoap
2
2
  # It takes a little while to load, so don't load it when rails loads.
3
- autoload :API, File.expand_path(File.join(File.dirname(__FILE__), 'debitech_soap/api'))
3
+ autoload :API, File.expand_path(File.join(File.dirname(__FILE__), "debitech_soap/api"))
4
4
  end
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), '../lib/debitech_soap'))
1
+ require File.expand_path(File.join(File.dirname(__FILE__), "../lib/debitech_soap"))
2
2
 
3
3
  class MockSoapResult
4
4
  class MockReturn
@@ -20,7 +20,7 @@ class MockSoapResultRuby19
20
20
  end
21
21
  end
22
22
 
23
- describe DebitechSoap::API do
23
+ RSpec.describe DebitechSoap::API do
24
24
  # When it can't find the wsdl file it throws an error. We need to ensure
25
25
  # it can find the file (fixed regression bug).
26
26
  it "can be initialized" do
@@ -28,68 +28,84 @@ describe DebitechSoap::API do
28
28
  end
29
29
  end
30
30
 
31
- describe DebitechSoap::API, "valid_credentials?" do
31
+ RSpec.describe DebitechSoap::API, "valid_credentials?" do
32
32
 
33
33
  before do
34
- @client = mock(Object)
35
- SOAP::WSDLDriverFactory.stub!(:new).and_return(mock(Object, :create_rpc_driver => @client))
34
+ @client = double("client")
35
+ allow(SOAP::WSDLDriverFactory).to receive(:new).and_return(double("a-factory", 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
+ expect(@client).to receive(:refund)
40
+ .with(shopName: "merchant_name", userName: "api_user_name", password: "api_user_password", verifyID: -1, amount: 0)
41
+ .and_return(double("refund", return: double("return", resultText: "error_transID_or_verifyID")))
42
42
 
43
- api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
44
- api.valid_credentials?.should == true
43
+ api = DebitechSoap::API.new(merchant: "merchant_name", username: "api_user_name", password: "api_user_password")
44
+
45
+ expect(api.valid_credentials?).to eq true
45
46
  end
46
47
 
47
- it "should return false if the service returns false" do
48
- @client.stub!(:checkSwedishPersNo).and_return(mock(Object, :return => "false"))
49
- api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
50
- api.valid_credentials?.should == false
48
+ it "should return false if the service returns an auth error" do
49
+ expect(@client).to receive(:refund).and_return(double("refund", return: double("return", resultText: "336 web_service_login_failed")))
50
+ api = DebitechSoap::API.new(merchant: "merchant_name", username: "api_user_name", password: "api_user_password")
51
+
52
+ expect(api.valid_credentials?).to eq false
53
+ end
54
+
55
+ it "raises if the service returns an unexpected result" do
56
+ expect(@client).to receive(:refund).and_return(double("refund", return: double("return", resultText: "let's have lunch")))
57
+ api = DebitechSoap::API.new(merchant: "merchant_name", username: "api_user_name", password: "api_user_password")
58
+
59
+ expect { api.valid_credentials? }.to raise_error(%{Unexpected result text: "let's have lunch"})
51
60
  end
52
61
 
53
62
  it "should work with Ruby 1.9 SOAP API" do
54
- @client.stub!(:checkSwedishPersNo).and_return(mock(Object, :m_return => "true"))
63
+ expect(@client).to receive(:refund).and_return(double("refund", m_return: double("m_return", resultText: "error_transID_or_verifyID")))
55
64
  api = DebitechSoap::API.new
56
- api.valid_credentials?.should == true
65
+
66
+ expect(api.valid_credentials?).to eq true
57
67
  end
58
68
 
59
69
  end
60
70
 
61
- describe DebitechSoap::API, "calling a method with java-style arguments" do
71
+ RSpec.describe DebitechSoap::API, "calling a method with java-style arguments" do
62
72
 
63
73
  before do
64
- @client = mock(Object)
65
- SOAP::WSDLDriverFactory.stub!(:new).and_return(mock(Object, :create_rpc_driver => @client))
74
+ @client = double("client")
75
+
76
+ expect(SOAP::WSDLDriverFactory).to receive(:new).and_return(double("a-factory", create_rpc_driver: @client))
66
77
  end
67
-
78
+
68
79
  it "should map the arguments to a hash and call the corresponding SOAP method" do
69
- api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
70
- @client.should_receive("refund").with(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra",
71
- :shopName => "merchant_name", :userName => "api_user_name", :password => "api_user_password").
72
- and_return(MockSoapResult.new)
80
+ api = DebitechSoap::API.new(merchant: "merchant_name", username: "api_user_name", password: "api_user_password")
81
+
82
+ expect(@client).to receive("refund")
83
+ .with(verifyID: 1234567, transID: 23456, amount: 100, extra: "extra", shopName: "merchant_name", userName: "api_user_name", password: "api_user_password")
84
+ .and_return(MockSoapResult.new)
85
+
73
86
  api.refund(1234567, 23456, 100, "extra")
74
87
  end
75
88
 
76
89
  it "should camel case method names" do
77
- api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
78
- @client.should_receive("authorize3DS").with(:verifyID => 1234567, :paRes => "RES", :extra => "extra",
79
- :shopName => "merchant_name", :userName => "api_user_name", :password => "api_user_password").
80
- and_return(MockSoapResult.new)
90
+ api = DebitechSoap::API.new(merchant: "merchant_name", username: "api_user_name", password: "api_user_password")
91
+
92
+ expect(@client).to receive("authorize3DS")
93
+ .with(verifyID: 1234567, paRes: "RES", extra: "extra", shopName: "merchant_name", userName: "api_user_name", password: "api_user_password")
94
+ .and_return(MockSoapResult.new)
95
+
81
96
  api.authorize_3ds(1234567, "RES", "extra")
82
97
  end
83
98
 
84
99
  it "should not keep old attributes when making subsequent api calls" do
85
- api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
86
- @client.should_receive("refund").with(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra",
87
- :shopName => "merchant_name", :userName => "api_user_name", :password => "api_user_password").
88
- and_return(MockSoapResult.new)
89
- @client.should_receive("authorize3DS").with(:verifyID => 1234567, :paRes => "RES", :extra => "extra",
90
- :shopName => "merchant_name", :userName => "api_user_name", :password => "api_user_password").
91
- and_return(MockSoapResult.new)
92
-
100
+ api = DebitechSoap::API.new(merchant: "merchant_name", username: "api_user_name", password: "api_user_password")
101
+
102
+ expect(@client).to receive("refund")
103
+ .with(verifyID: 1234567, transID: 23456, amount: 100, extra: "extra", shopName: "merchant_name", userName: "api_user_name", password: "api_user_password")
104
+ .and_return(MockSoapResult.new)
105
+ expect(@client).to receive("authorize3DS")
106
+ .with(verifyID: 1234567, paRes: "RES", extra: "extra", shopName: "merchant_name", userName: "api_user_name", password: "api_user_password")
107
+ .and_return(MockSoapResult.new)
108
+
93
109
  api.refund(1234567, 23456, 100, "extra")
94
110
  api.authorize3DS(1234567, "RES", "extra")
95
111
  end
@@ -97,107 +113,136 @@ describe DebitechSoap::API, "calling a method with java-style arguments" do
97
113
  it "should create a return object" do
98
114
  api = DebitechSoap::API.new
99
115
  mock_soap_result = MockSoapResult.new
100
- mock_soap_result.return.stub!(:resultText).and_return("success")
101
- @client.stub!("refund").and_return(mock_soap_result)
102
- api.refund(1234567, 23456, 100, "extra").resultText.should == "success"
116
+ expect(mock_soap_result.return).to receive(:resultText).and_return("success")
117
+ expect(@client).to receive(:refund).and_return(mock_soap_result)
118
+
119
+ expect(api.refund(1234567, 23456, 100, "extra").resultText).to eq "success"
103
120
  end
104
121
 
105
122
  it "should return nil when there is no data" do
106
123
  api = DebitechSoap::API.new
107
124
  mock_soap_result = MockSoapResult.new
108
- @client.stub!("refund").and_return(mock_soap_result)
109
- api.refund(1234567, 23456, 100, "extra").resultCode.should be_nil
125
+ expect(@client).to receive(:refund).and_return(mock_soap_result)
126
+
127
+ expect(api.refund(1234567, 23456, 100, "extra").resultCode).to be_nil
110
128
  end
111
129
 
112
130
  it "should be able to access the data using getCamelCase, get_underscore and underscore methods" do
113
131
  api = DebitechSoap::API.new
114
132
  mock_soap_result = MockSoapResult.new
115
- mock_soap_result.return.stub!(:resultText).and_return("success")
116
- @client.stub!("refund").and_return(mock_soap_result)
133
+ expect(mock_soap_result.return).to receive(:resultText).and_return("success")
134
+ expect(@client).to receive(:refund).and_return(mock_soap_result)
135
+
117
136
  result = api.refund(1234567, 23456, 100, "extra")
118
- result.getResultText.should == "success"
119
- result.get_result_text.should == "success"
120
- result.result_text.should == 'success'
137
+
138
+ expect(result.getResultText).to eq "success"
139
+ expect(result.get_result_text).to eq "success"
140
+ expect(result.result_text).to eq "success"
121
141
  end
122
142
 
123
143
  it "should convert the result to an integer when its a number" do
124
144
  api = DebitechSoap::API.new
125
145
  mock_soap_result = MockSoapResult.new
126
- mock_soap_result.return.stub!(:resultCode).and_return("100")
127
- @client.stub!("refund").and_return(mock_soap_result)
146
+ expect(mock_soap_result.return).to receive(:resultCode).and_return("100")
147
+
148
+ expect(@client).to receive(:refund).and_return(mock_soap_result)
149
+
128
150
  result = api.refund(1234567, 23456, 100, "extra")
129
- result.resultCode.should == 100
130
- result.getResultCode.should == 100
131
- result.get_result_code.should == 100
151
+ expect(result.resultCode).to eq 100
152
+ expect(result.getResultCode).to eq 100
153
+ expect(result.get_result_code).to eq 100
132
154
  end
133
155
 
134
156
  it "should convert the result to an integer when its zero" do
135
157
  api = DebitechSoap::API.new
136
158
  mock_soap_result = MockSoapResult.new
137
- mock_soap_result.return.stub!(:resultCode).and_return("0")
138
- @client.stub!("refund").and_return(mock_soap_result)
159
+ expect(mock_soap_result.return).to receive(:resultCode).and_return("0")
160
+ expect(@client).to receive(:refund).and_return(mock_soap_result)
161
+
139
162
  result = api.refund(1234567, 23456, 100, "extra")
140
- result.resultCode.should == 0
163
+
164
+ expect(result.resultCode).to eq 0
141
165
  end
142
166
 
143
167
  it "should work with Ruby 1.9 SOAP API" do
144
168
  api = DebitechSoap::API.new
145
169
  mock_soap_result = MockSoapResultRuby19.new
146
- mock_soap_result.m_return.stub!(:resultCode).and_return("0")
147
- @client.stub!("refund").and_return(mock_soap_result)
170
+ expect(mock_soap_result.m_return).to receive(:resultCode).and_return("0")
171
+ expect(@client).to receive(:refund).and_return(mock_soap_result)
172
+
148
173
  result = api.refund(1234567, 23456, 100, "extra")
149
- result.resultCode.should == 0
150
- end
151
174
 
175
+ expect(result.resultCode).to eq 0
176
+ end
152
177
  end
153
178
 
154
- describe DebitechSoap::API, "calling a method with hash-style arguments" do
179
+ RSpec.describe DebitechSoap::API, "calling a method with hash-style arguments" do
155
180
 
156
181
  before do
157
- @client = mock(Object)
158
- SOAP::WSDLDriverFactory.stub!(:new).and_return(mock(Object, :create_rpc_driver => @client))
182
+ @client = double("client")
183
+ expect(SOAP::WSDLDriverFactory).to receive(:new).and_return(double("factory", create_rpc_driver: @client))
159
184
  end
160
185
 
161
186
  it "should call the corresponding soap method" do
162
- api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
163
- @client.should_receive("refund").with(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra",
164
- :shopName => "merchant_name", :userName => "api_user_name", :password => "api_user_password").
165
- and_return(MockSoapResult.new)
166
- api.refund(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra")
187
+ api = DebitechSoap::API.new(merchant: "merchant_name", username: "api_user_name", password: "api_user_password")
188
+ expect(@client).to receive("refund")
189
+ .with(verifyID: 1234567, transID: 23456, amount: 100, extra: "extra", shopName: "merchant_name", userName: "api_user_name", password: "api_user_password")
190
+ .and_return(MockSoapResult.new)
191
+ api.refund(verifyID: 1234567, transID: 23456, amount: 100, extra: "extra")
167
192
  end
168
193
 
169
194
  it "should return data" do
170
195
  api = DebitechSoap::API.new
171
196
  mock_soap_result = MockSoapResult.new
172
- mock_soap_result.return.stub!(:resultText).and_return("success")
173
- @client.stub!("refund").and_return(mock_soap_result)
174
- api.refund(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra").getResultText.should == "success"
197
+ expect(mock_soap_result.return).to receive(:resultText).and_return("success")
198
+ expect(@client).to receive("refund").and_return(mock_soap_result)
199
+
200
+ expect(api.refund(verifyID: 1234567, transID: 23456, amount: 100, extra: "extra").getResultText).to eq "success"
175
201
  end
176
202
 
177
203
  it "should work with Ruby 1.9 SOAP API" do
178
204
  api = DebitechSoap::API.new
179
205
  mock_soap_result = MockSoapResultRuby19.new
180
- mock_soap_result.m_return.stub!(:resultText).and_return("success")
181
- @client.stub!("refund").and_return(mock_soap_result)
182
- result = api.refund(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra")
183
- result.getResultText.should == "success"
184
- end
206
+ expect(mock_soap_result.m_return).to receive(:resultText).and_return("success")
207
+ expect(@client).to receive(:refund).and_return(mock_soap_result)
185
208
 
209
+ result = api.refund(verifyID: 1234567, transID: 23456, amount: 100, extra: "extra")
210
+
211
+ expect(result.getResultText).to eq "success"
212
+ end
186
213
  end
187
214
 
188
- describe DebitechSoap::API, "handling exceptions" do
215
+ RSpec.describe DebitechSoap::API, "handling exceptions" do
189
216
 
190
217
  before do
191
- @client = mock(Object)
192
- SOAP::WSDLDriverFactory.stub!(:new).and_return(mock(Object, :create_rpc_driver => @client))
218
+ @client = double
219
+ expect(SOAP::WSDLDriverFactory).to receive(:new).and_return(double("factory", create_rpc_driver: @client))
193
220
  end
194
221
 
195
222
  it "should catch Timeout::Error and return 403" do
196
223
  api = DebitechSoap::API.new
197
- @client.stub!("refund").and_raise(Timeout::Error)
198
- result = api.refund(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra")
199
- result.getResultCode.should == 403
200
- result.getResultText.should == "SOAP Timeout"
224
+ expect(@client).to receive(:refund).and_raise(Timeout::Error)
225
+ result = api.refund(verifyID: 1234567, transID: 23456, amount: 100, extra: "extra")
226
+
227
+ expect(result.getResultCode).to eq 403
228
+ expect(result.getResultText).to eq "SOAP Timeout"
229
+ end
230
+ end
231
+
232
+ RSpec.describe DebitechSoap::API, "overriding ciphers with ENV" do
233
+ around do |example|
234
+ old_env = ENV["DIBS_HTTPCLIENT_CIPHERS"]
235
+ ENV["DIBS_HTTPCLIENT_CIPHERS"] = "FOO"
236
+ example.run
237
+ ENV["DIBS_HTTPCLIENT_CIPHERS"] = old_env
238
+ end
239
+
240
+ it "changes the configured HTTPClient ciphers" do
241
+ api = DebitechSoap::API.new
242
+
243
+ httpclient = api.instance_variable_get("@client").streamhandler.client
244
+
245
+ expect(httpclient).to be_instance_of HTTPClient
246
+ expect(httpclient.ssl_config.ciphers).to eq "FOO"
201
247
  end
202
-
203
248
  end
@@ -0,0 +1,3 @@
1
+ RSpec.configure do |config|
2
+ config.expect_with(:rspec) { |c| c.syntax = :expect }
3
+ end
metadata CHANGED
@@ -1,116 +1,62 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: debitech_soap
3
- version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 2
10
- version: 1.0.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.1
11
5
  platform: ruby
12
- authors:
13
- - "Joakim Kolsj\xC3\xB6"
6
+ authors:
7
+ - Joakim Kolsjö
14
8
  - Niklas Holmgren
15
9
  - Henrik Nyh
16
10
  - Daniel Eriksson
17
11
  autorequire:
18
12
  bindir: bin
19
13
  cert_chain: []
20
-
21
- date: 2013-05-21 00:00:00 Z
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
24
- name: mumboe-soap4r
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
27
- none: false
28
- requirements:
29
- - - ~>
30
- - !ruby/object:Gem::Version
31
- hash: 95
32
- segments:
33
- - 1
34
- - 5
35
- - 8
36
- - 4
37
- version: 1.5.8.4
38
- type: :runtime
39
- version_requirements: *id001
40
- - !ruby/object:Gem::Dependency
41
- name: rake
42
- prerelease: false
43
- requirement: &id002 !ruby/object:Gem::Requirement
44
- none: false
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- hash: 3
49
- segments:
50
- - 0
51
- version: "0"
52
- type: :development
53
- version_requirements: *id002
54
- - !ruby/object:Gem::Dependency
55
- name: rspec
56
- prerelease: false
57
- requirement: &id003 !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
14
+ date: 2021-11-19 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: httpclient
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
60
20
  - - ">="
61
- - !ruby/object:Gem::Version
62
- hash: 3
63
- segments:
64
- - 0
65
- version: "0"
66
- type: :development
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- name: guard
21
+ - !ruby/object:Gem::Version
22
+ version: 2.4.0
23
+ type: :runtime
70
24
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
74
27
  - - ">="
75
- - !ruby/object:Gem::Version
76
- hash: 3
77
- segments:
78
- - 0
79
- version: "0"
80
- type: :development
81
- version_requirements: *id004
82
- - !ruby/object:Gem::Dependency
83
- name: guard-rspec
28
+ - !ruby/object:Gem::Version
29
+ version: 2.4.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: mumboe-soap4r
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: 1.5.8.4
37
+ type: :runtime
84
38
  prerelease: false
85
- requirement: &id005 !ruby/object:Gem::Requirement
86
- none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- hash: 3
91
- segments:
92
- - 0
93
- version: "0"
94
- type: :development
95
- version_requirements: *id005
96
- description: An implementation of the DebiTech Java API using pure ruby and the SOAP API.
97
- email:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: 1.5.8.4
44
+ description: An implementation of the DebiTech Java API using pure ruby and the SOAP
45
+ API.
46
+ email:
98
47
  - joakim.kolsjo@gmail.com
99
48
  - niklas.holmgren@bukowskis.com
100
49
  - henrik@barsoom.se
101
50
  executables: []
102
-
103
51
  extensions: []
104
-
105
52
  extra_rdoc_files: []
106
-
107
- files:
108
- - .gitignore
109
- - .rvmrc
110
- - .travis.yml
53
+ files:
54
+ - ".github/workflows/ci.yml"
55
+ - ".gitignore"
56
+ - ".rubocop.yml"
57
+ - ".rvmrc"
111
58
  - CHANGELOG
112
59
  - Gemfile
113
- - Gemfile.lock
114
60
  - Guardfile
115
61
  - LICENCE
116
62
  - README.markdown
@@ -122,38 +68,28 @@ files:
122
68
  - lib/debitech_soap/version.rb
123
69
  - lib/service.wsdl
124
70
  - spec/debitech_soap_spec.rb
125
- homepage: http://github.com/joakimk/debitech_soap
71
+ - spec/spec_helper.rb
72
+ homepage: http://github.com/barsoom/debitech_soap
126
73
  licenses: []
127
-
74
+ metadata:
75
+ rubygems_mfa_required: 'true'
128
76
  post_install_message:
129
77
  rdoc_options: []
130
-
131
- require_paths:
78
+ require_paths:
132
79
  - lib
133
- required_ruby_version: !ruby/object:Gem::Requirement
134
- none: false
135
- requirements:
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
136
82
  - - ">="
137
- - !ruby/object:Gem::Version
138
- hash: 3
139
- segments:
140
- - 0
141
- version: "0"
142
- required_rubygems_version: !ruby/object:Gem::Requirement
143
- none: false
144
- requirements:
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
145
87
  - - ">="
146
- - !ruby/object:Gem::Version
147
- hash: 3
148
- segments:
149
- - 0
150
- version: "0"
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
151
90
  requirements: []
152
-
153
- rubyforge_project:
154
- rubygems_version: 1.8.25
91
+ rubygems_version: 3.2.28
155
92
  signing_key:
156
- specification_version: 3
93
+ specification_version: 4
157
94
  summary: A pure ruby way to make payments with DebiTech
158
- test_files:
159
- - spec/debitech_soap_spec.rb
95
+ test_files: []
data/.travis.yml DELETED
@@ -1,3 +0,0 @@
1
- rvm:
2
- - ree
3
-
data/Gemfile.lock DELETED
@@ -1,37 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- debitech_soap (1.0.1)
5
- mumboe-soap4r (~> 1.5.8.4)
6
-
7
- GEM
8
- remote: http://rubygems.org/
9
- specs:
10
- diff-lcs (1.1.3)
11
- guard (0.8.8)
12
- thor (~> 0.14.6)
13
- guard-rspec (0.5.0)
14
- guard (>= 0.8.4)
15
- httpclient (2.3.3)
16
- mumboe-soap4r (1.5.8.6)
17
- httpclient (>= 2.1.1)
18
- rake (0.9.2)
19
- rspec (2.7.0)
20
- rspec-core (~> 2.7.0)
21
- rspec-expectations (~> 2.7.0)
22
- rspec-mocks (~> 2.7.0)
23
- rspec-core (2.7.1)
24
- rspec-expectations (2.7.0)
25
- diff-lcs (~> 1.1.2)
26
- rspec-mocks (2.7.0)
27
- thor (0.14.6)
28
-
29
- PLATFORMS
30
- ruby
31
-
32
- DEPENDENCIES
33
- debitech_soap!
34
- guard
35
- guard-rspec
36
- rake
37
- rspec