debitech_soap 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 27d41ad832b2eba41d08b3aa17b750a104fe92d9
4
- data.tar.gz: e55ad817106d4bf04ffd0c84b9a3926aebc9119f
2
+ SHA256:
3
+ metadata.gz: bd72f376fc8244561d542048c01a2a67f3c6af855b7f5d1f48e79d334935f62c
4
+ data.tar.gz: 58f219906628833960645ee107abed6384bccc57816a56bb7b5d3521b120fbaa
5
5
  SHA512:
6
- metadata.gz: 6e05d146e4c3f7ded0a9fc6fe19edfa3ce6c838368db5b1b58cca9b1600cec63d3510440f9064bfacdbb8d75d947ff4622ef0c805da924c82b53cec570f4b991
7
- data.tar.gz: fcf23bc8f637d58d2d42bbd17c7f43576d462b5c888a3cf54beab2e92f6e91c5f2b4496526d56d6f3792cb829c1d44f976db7703fb9e94fccde2d97c1772065b
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
 
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,11 +6,12 @@ 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
16
  # Earlier versions of HTTPClient may prefer SSLv3 as its ssl_version,
16
17
  # but 2014-10-15 Debitech started having issues with SSLv3, sometimes returning
@@ -21,13 +22,6 @@ Gem::Specification.new do |s|
21
22
 
22
23
  s.add_dependency "mumboe-soap4r", "~> 1.5.8.4"
23
24
 
24
- s.add_development_dependency "rake"
25
- s.add_development_dependency 'rspec'
26
- s.add_development_dependency "guard"
27
- s.add_development_dependency "guard-rspec"
28
-
29
25
  s.files = `git ls-files`.split("\n")
30
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
31
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
32
- s.require_paths = ["lib"]
26
+ s.require_paths = [ "lib" ]
33
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 = {}
@@ -58,7 +52,7 @@ module DebitechSoap
58
52
  disable_stderr do
59
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.
60
54
  # 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 })))
55
+ response_value = return_value(@client.refund(@api_credentials.merge({ verifyID: -1, amount: 0 })))
62
56
  result_text = response_value.resultText
63
57
 
64
58
  case result_text
@@ -89,18 +83,18 @@ module DebitechSoap
89
83
  define_method(method) do |*args| # def refund(*args)
90
84
  attributes = @api_credentials.clone
91
85
 
92
- if args.first.is_a?(Hash)
86
+ if args.first.is_a?(Hash)
93
87
  attributes.merge!(args.first)
94
88
  else
95
89
  parameter_order = api_signature(method).last
96
90
  args.each_with_index { |argument, i|
97
91
  attributes[parameter_order[i].to_sym] = argument
98
92
  }
99
- end
93
+ end
100
94
  begin
101
95
  client_result = return_value(@client.send(api_signature(method).first.first, attributes))
102
96
  rescue Timeout::Error
103
- client_result = OpenStruct.new(:resultCode => 403, :resultText => "SOAP Timeout")
97
+ client_result = OpenStruct.new(resultCode: 403, resultText: "SOAP Timeout")
104
98
  return return_data(client_result)
105
99
  end
106
100
  return_data(client_result)
@@ -130,16 +124,14 @@ module DebitechSoap
130
124
  end
131
125
 
132
126
  def disable_stderr
133
- begin
134
- $stderr = File.open('/dev/null', 'w')
135
- yield
136
- ensure
137
- $stderr = STDERR
138
- end
127
+ $stderr = File.open("/dev/null", "w")
128
+ yield
129
+ ensure
130
+ $stderr = STDERR
139
131
  end
140
132
 
141
133
  def api_signature(method)
142
- PARAMS.find {|key,value| key.include?(method.to_s) }
134
+ PARAMS.find { |key, value| key.include?(method.to_s) }
143
135
  end
144
136
 
145
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.2.0"
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,74 +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
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")))
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
48
  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
- api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
50
- api.valid_credentials?.should == false
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
51
53
  end
52
54
 
53
55
  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(@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
+
56
59
  expect { api.valid_credentials? }.to raise_error(%{Unexpected result text: "let's have lunch"})
57
60
  end
58
61
 
59
62
  it "should work with Ruby 1.9 SOAP API" do
60
- @client.stub!(:refund).and_return(mock(Object, :m_return => mock(Object, :resultText => "error_transID_or_verifyID")))
63
+ expect(@client).to receive(:refund).and_return(double("refund", m_return: double("m_return", resultText: "error_transID_or_verifyID")))
61
64
  api = DebitechSoap::API.new
62
- api.valid_credentials?.should == true
65
+
66
+ expect(api.valid_credentials?).to eq true
63
67
  end
64
68
 
65
69
  end
66
70
 
67
- describe DebitechSoap::API, "calling a method with java-style arguments" do
71
+ RSpec.describe DebitechSoap::API, "calling a method with java-style arguments" do
68
72
 
69
73
  before do
70
- @client = mock(Object)
71
- 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))
72
77
  end
73
-
78
+
74
79
  it "should map the arguments to a hash and call the corresponding SOAP method" do
75
- api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
76
- @client.should_receive("refund").with(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra",
77
- :shopName => "merchant_name", :userName => "api_user_name", :password => "api_user_password").
78
- 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
+
79
86
  api.refund(1234567, 23456, 100, "extra")
80
87
  end
81
88
 
82
89
  it "should camel case method names" do
83
- api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
84
- @client.should_receive("authorize3DS").with(:verifyID => 1234567, :paRes => "RES", :extra => "extra",
85
- :shopName => "merchant_name", :userName => "api_user_name", :password => "api_user_password").
86
- 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
+
87
96
  api.authorize_3ds(1234567, "RES", "extra")
88
97
  end
89
98
 
90
99
  it "should not keep old attributes when making subsequent api calls" do
91
- api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
92
- @client.should_receive("refund").with(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra",
93
- :shopName => "merchant_name", :userName => "api_user_name", :password => "api_user_password").
94
- and_return(MockSoapResult.new)
95
- @client.should_receive("authorize3DS").with(:verifyID => 1234567, :paRes => "RES", :extra => "extra",
96
- :shopName => "merchant_name", :userName => "api_user_name", :password => "api_user_password").
97
- and_return(MockSoapResult.new)
98
-
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
+
99
109
  api.refund(1234567, 23456, 100, "extra")
100
110
  api.authorize3DS(1234567, "RES", "extra")
101
111
  end
@@ -103,112 +113,123 @@ describe DebitechSoap::API, "calling a method with java-style arguments" do
103
113
  it "should create a return object" do
104
114
  api = DebitechSoap::API.new
105
115
  mock_soap_result = MockSoapResult.new
106
- mock_soap_result.return.stub!(:resultText).and_return("success")
107
- @client.stub!("refund").and_return(mock_soap_result)
108
- 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"
109
120
  end
110
121
 
111
122
  it "should return nil when there is no data" do
112
123
  api = DebitechSoap::API.new
113
124
  mock_soap_result = MockSoapResult.new
114
- @client.stub!("refund").and_return(mock_soap_result)
115
- 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
116
128
  end
117
129
 
118
130
  it "should be able to access the data using getCamelCase, get_underscore and underscore methods" do
119
131
  api = DebitechSoap::API.new
120
132
  mock_soap_result = MockSoapResult.new
121
- mock_soap_result.return.stub!(:resultText).and_return("success")
122
- @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
+
123
136
  result = api.refund(1234567, 23456, 100, "extra")
124
- result.getResultText.should == "success"
125
- result.get_result_text.should == "success"
126
- 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"
127
141
  end
128
142
 
129
143
  it "should convert the result to an integer when its a number" do
130
144
  api = DebitechSoap::API.new
131
145
  mock_soap_result = MockSoapResult.new
132
- mock_soap_result.return.stub!(:resultCode).and_return("100")
133
- @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
+
134
150
  result = api.refund(1234567, 23456, 100, "extra")
135
- result.resultCode.should == 100
136
- result.getResultCode.should == 100
137
- 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
138
154
  end
139
155
 
140
156
  it "should convert the result to an integer when its zero" do
141
157
  api = DebitechSoap::API.new
142
158
  mock_soap_result = MockSoapResult.new
143
- mock_soap_result.return.stub!(:resultCode).and_return("0")
144
- @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
+
145
162
  result = api.refund(1234567, 23456, 100, "extra")
146
- result.resultCode.should == 0
163
+
164
+ expect(result.resultCode).to eq 0
147
165
  end
148
166
 
149
167
  it "should work with Ruby 1.9 SOAP API" do
150
168
  api = DebitechSoap::API.new
151
169
  mock_soap_result = MockSoapResultRuby19.new
152
- mock_soap_result.m_return.stub!(:resultCode).and_return("0")
153
- @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
+
154
173
  result = api.refund(1234567, 23456, 100, "extra")
155
- result.resultCode.should == 0
156
- end
157
174
 
175
+ expect(result.resultCode).to eq 0
176
+ end
158
177
  end
159
178
 
160
- describe DebitechSoap::API, "calling a method with hash-style arguments" do
179
+ RSpec.describe DebitechSoap::API, "calling a method with hash-style arguments" do
161
180
 
162
181
  before do
163
- @client = mock(Object)
164
- 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))
165
184
  end
166
185
 
167
186
  it "should call the corresponding soap method" do
168
- api = DebitechSoap::API.new(:merchant => "merchant_name", :username => "api_user_name", :password => "api_user_password")
169
- @client.should_receive("refund").with(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra",
170
- :shopName => "merchant_name", :userName => "api_user_name", :password => "api_user_password").
171
- and_return(MockSoapResult.new)
172
- 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")
173
192
  end
174
193
 
175
194
  it "should return data" do
176
195
  api = DebitechSoap::API.new
177
196
  mock_soap_result = MockSoapResult.new
178
- mock_soap_result.return.stub!(:resultText).and_return("success")
179
- @client.stub!("refund").and_return(mock_soap_result)
180
- 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"
181
201
  end
182
202
 
183
203
  it "should work with Ruby 1.9 SOAP API" do
184
204
  api = DebitechSoap::API.new
185
205
  mock_soap_result = MockSoapResultRuby19.new
186
- mock_soap_result.m_return.stub!(:resultText).and_return("success")
187
- @client.stub!("refund").and_return(mock_soap_result)
188
- result = api.refund(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra")
189
- result.getResultText.should == "success"
190
- 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)
191
208
 
209
+ result = api.refund(verifyID: 1234567, transID: 23456, amount: 100, extra: "extra")
210
+
211
+ expect(result.getResultText).to eq "success"
212
+ end
192
213
  end
193
214
 
194
- describe DebitechSoap::API, "handling exceptions" do
215
+ RSpec.describe DebitechSoap::API, "handling exceptions" do
195
216
 
196
217
  before do
197
- @client = mock(Object)
198
- 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))
199
220
  end
200
221
 
201
222
  it "should catch Timeout::Error and return 403" do
202
223
  api = DebitechSoap::API.new
203
- @client.stub!("refund").and_raise(Timeout::Error)
204
- result = api.refund(:verifyID => 1234567, :transID => 23456, :amount => 100, :extra => "extra")
205
- result.getResultCode.should == 403
206
- 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"
207
229
  end
208
-
209
230
  end
210
231
 
211
- describe DebitechSoap::API, "overriding ciphers with ENV" do
232
+ RSpec.describe DebitechSoap::API, "overriding ciphers with ENV" do
212
233
  around do |example|
213
234
  old_env = ENV["DIBS_HTTPCLIENT_CIPHERS"]
214
235
  ENV["DIBS_HTTPCLIENT_CIPHERS"] = "FOO"
@@ -221,7 +242,7 @@ describe DebitechSoap::API, "overriding ciphers with ENV" do
221
242
 
222
243
  httpclient = api.instance_variable_get("@client").streamhandler.client
223
244
 
224
- httpclient.should be_instance_of HTTPClient
225
- httpclient.ssl_config.ciphers.should == "FOO"
245
+ expect(httpclient).to be_instance_of HTTPClient
246
+ expect(httpclient.ssl_config.ciphers).to eq "FOO"
226
247
  end
227
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debitech_soap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
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-12-08 00:00:00.000000000 Z
14
+ date: 2021-11-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: httpclient
@@ -41,62 +41,6 @@ dependencies:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
43
  version: 1.5.8.4
44
- - !ruby/object:Gem::Dependency
45
- name: rake
46
- requirement: !ruby/object:Gem::Requirement
47
- requirements:
48
- - - ">="
49
- - !ruby/object:Gem::Version
50
- version: '0'
51
- type: :development
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: '0'
58
- - !ruby/object:Gem::Dependency
59
- name: rspec
60
- requirement: !ruby/object:Gem::Requirement
61
- requirements:
62
- - - ">="
63
- - !ruby/object:Gem::Version
64
- version: '0'
65
- type: :development
66
- prerelease: false
67
- version_requirements: !ruby/object:Gem::Requirement
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: '0'
72
- - !ruby/object:Gem::Dependency
73
- name: guard
74
- requirement: !ruby/object:Gem::Requirement
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: '0'
79
- type: :development
80
- prerelease: false
81
- version_requirements: !ruby/object:Gem::Requirement
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- - !ruby/object:Gem::Dependency
87
- name: guard-rspec
88
- requirement: !ruby/object:Gem::Requirement
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: '0'
93
- type: :development
94
- prerelease: false
95
- version_requirements: !ruby/object:Gem::Requirement
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: '0'
100
44
  description: An implementation of the DebiTech Java API using pure ruby and the SOAP
101
45
  API.
102
46
  email:
@@ -107,12 +51,12 @@ executables: []
107
51
  extensions: []
108
52
  extra_rdoc_files: []
109
53
  files:
54
+ - ".github/workflows/ci.yml"
110
55
  - ".gitignore"
56
+ - ".rubocop.yml"
111
57
  - ".rvmrc"
112
- - ".travis.yml"
113
58
  - CHANGELOG
114
59
  - Gemfile
115
- - Gemfile.lock
116
60
  - Guardfile
117
61
  - LICENCE
118
62
  - README.markdown
@@ -124,9 +68,11 @@ files:
124
68
  - lib/debitech_soap/version.rb
125
69
  - lib/service.wsdl
126
70
  - spec/debitech_soap_spec.rb
127
- homepage: http://github.com/joakimk/debitech_soap
71
+ - spec/spec_helper.rb
72
+ homepage: http://github.com/barsoom/debitech_soap
128
73
  licenses: []
129
- metadata: {}
74
+ metadata:
75
+ rubygems_mfa_required: 'true'
130
76
  post_install_message:
131
77
  rdoc_options: []
132
78
  require_paths:
@@ -142,10 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
88
  - !ruby/object:Gem::Version
143
89
  version: '0'
144
90
  requirements: []
145
- rubyforge_project:
146
- rubygems_version: 2.6.11
91
+ rubygems_version: 3.2.28
147
92
  signing_key:
148
93
  specification_version: 4
149
94
  summary: A pure ruby way to make payments with DebiTech
150
- test_files:
151
- - 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,41 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- debitech_soap (1.1.1)
5
- httpclient (>= 2.4.0)
6
- mumboe-soap4r (~> 1.5.8.4)
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- diff-lcs (1.1.3)
12
- guard (0.8.8)
13
- thor (~> 0.14.6)
14
- guard-rspec (0.5.0)
15
- guard (>= 0.8.4)
16
- httpclient (2.8.3)
17
- mumboe-soap4r (1.5.8.7)
18
- httpclient (>= 2.1.1)
19
- rake (0.9.2)
20
- rspec (2.7.0)
21
- rspec-core (~> 2.7.0)
22
- rspec-expectations (~> 2.7.0)
23
- rspec-mocks (~> 2.7.0)
24
- rspec-core (2.7.1)
25
- rspec-expectations (2.7.0)
26
- diff-lcs (~> 1.1.2)
27
- rspec-mocks (2.7.0)
28
- thor (0.14.6)
29
-
30
- PLATFORMS
31
- ruby
32
-
33
- DEPENDENCIES
34
- debitech_soap!
35
- guard
36
- guard-rspec
37
- rake
38
- rspec
39
-
40
- BUNDLED WITH
41
- 1.15.4