datatrans 5.0.0 → 5.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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +37 -4
  3. data/.github/workflows/release.yml +1 -1
  4. data/.gitignore +1 -1
  5. data/.ruby-version +1 -1
  6. data/Appraisals +16 -8
  7. data/CHANGELOG.md +22 -0
  8. data/Gemfile +1 -0
  9. data/Gemfile.lock +151 -0
  10. data/README.markdown +183 -3
  11. data/Rakefile +2 -2
  12. data/datatrans.gemspec +20 -22
  13. data/gemfiles/rails_5_2.gemfile +2 -2
  14. data/gemfiles/rails_6_0.gemfile +2 -2
  15. data/gemfiles/rails_6_1.gemfile +2 -2
  16. data/gemfiles/rails_7_0.gemfile +2 -2
  17. data/gemfiles/rails_7_1.gemfile +12 -0
  18. data/lib/datatrans/common.rb +5 -5
  19. data/lib/datatrans/config.rb +41 -12
  20. data/lib/datatrans/json/transaction/authorize.rb +10 -0
  21. data/lib/datatrans/json/transaction/init.rb +61 -0
  22. data/lib/datatrans/json/transaction/merchant_authorize.rb +45 -0
  23. data/lib/datatrans/json/transaction/response.rb +26 -0
  24. data/lib/datatrans/json/transaction/settle.rb +41 -0
  25. data/lib/datatrans/json/transaction/status.rb +50 -0
  26. data/lib/datatrans/json/transaction.rb +54 -0
  27. data/lib/datatrans/version.rb +1 -1
  28. data/lib/datatrans/web/transaction/authorize.rb +46 -17
  29. data/lib/datatrans/web/transaction.rb +10 -4
  30. data/lib/datatrans/web/view_helper.rb +3 -1
  31. data/lib/datatrans/xml/transaction/authorize.rb +39 -19
  32. data/lib/datatrans/xml/transaction/capture.rb +29 -15
  33. data/lib/datatrans/xml/transaction/request.rb +10 -9
  34. data/lib/datatrans/xml/transaction/response.rb +4 -2
  35. data/lib/datatrans/xml/transaction/status.rb +41 -25
  36. data/lib/datatrans/xml/transaction/void.rb +30 -16
  37. data/lib/datatrans/xml/transaction.rb +18 -14
  38. data/lib/datatrans.rb +9 -8
  39. data/renovate.json +14 -0
  40. data/spec/common_spec.rb +6 -6
  41. data/spec/config_spec.rb +8 -2
  42. data/spec/json/authorize_spec.rb +100 -0
  43. data/spec/json/init_spec.rb +100 -0
  44. data/spec/json/merchant_authorize_spec.rb +97 -0
  45. data/spec/json/settle_spec.rb +55 -0
  46. data/spec/json/status_spec.rb +75 -0
  47. data/spec/json/transaction_spec.rb +10 -0
  48. data/spec/spec_helper.rb +11 -11
  49. data/spec/web/init_spec.rb +157 -0
  50. data/spec/xml/capture_spec.rb +5 -5
  51. data/spec/xml/{authorize_spec.rb → init_spec.rb} +7 -7
  52. data/spec/xml/request_spec.rb +21 -22
  53. data/spec/xml/status_spec.rb +4 -4
  54. data/spec/xml/void_spec.rb +5 -5
  55. metadata +20 -4
  56. data/spec/web/authorize_spec.rb +0 -157
@@ -1,12 +1,12 @@
1
- require 'datatrans/xml/transaction/request'
2
- require 'datatrans/xml/transaction/response'
1
+ require "datatrans/xml/transaction/request"
2
+ require "datatrans/xml/transaction/response"
3
3
 
4
4
  class Datatrans::XML::Transaction
5
5
  class AuthorizeRequest < Request
6
6
  def process
7
- post(self.datatrans.url(:xml_authorize_url),
8
- :headers => { 'Content-Type' => 'text/xml' },
9
- :body => build_authorize_request.to_s).parsed_response
7
+ post(datatrans.url(:xml_authorize_url),
8
+ headers: {"Content-Type" => "text/xml"},
9
+ body: build_authorize_request.to_s).parsed_response
10
10
  end
11
11
 
12
12
  private
@@ -18,60 +18,80 @@ class Datatrans::XML::Transaction
18
18
  xml.aliasCC params[:aliasCC]
19
19
  xml.expm params[:expm]
20
20
  xml.expy params[:expy]
21
- xml.sign sign(self.datatrans.merchant_id, params[:amount], params[:currency], params[:refno])
21
+ xml.sign sign(datatrans.merchant_id, params[:amount], params[:currency], params[:refno])
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
26
  class AuthorizeResponse < Response
27
27
  def successful?
28
- response_code == '01' && response_message == 'Authorized'
28
+ response_code == "01" && response_message == "Authorized"
29
29
  end
30
30
 
31
31
  def response_code
32
- params_root_node['response']['responseCode'] rescue nil
32
+ params_root_node["response"]["responseCode"]
33
+ rescue
34
+ nil
33
35
  end
34
36
 
35
37
  def response_message
36
- params_root_node['response']['responseMessage'] rescue nil
38
+ params_root_node["response"]["responseMessage"]
39
+ rescue
40
+ nil
37
41
  end
38
42
 
39
43
  def transaction_id
40
- params_root_node['response']['uppTransactionId'] rescue nil
44
+ params_root_node["response"]["uppTransactionId"]
45
+ rescue
46
+ nil
41
47
  end
42
48
 
43
49
  def reference_number
44
- params_root_node['refno'] rescue nil
50
+ params_root_node["refno"]
51
+ rescue
52
+ nil
45
53
  end
46
54
 
47
55
  def authorization_code
48
- params_root_node['response']['authorizationCode'] rescue nil
56
+ params_root_node["response"]["authorizationCode"]
57
+ rescue
58
+ nil
49
59
  end
50
60
 
51
61
  def masked_cc
52
- params_root_node['response']['maskedCC'] rescue nil
62
+ params_root_node["response"]["maskedCC"]
63
+ rescue
64
+ nil
53
65
  end
54
66
 
55
67
  def creditcard_alias
56
- params_root_node['request']['aliasCC'] rescue nil
68
+ params_root_node["request"]["aliasCC"]
69
+ rescue
70
+ nil
57
71
  end
58
72
 
59
73
  def error_code
60
- params_root_node['error']['errorCode'] rescue nil
74
+ params_root_node["error"]["errorCode"]
75
+ rescue
76
+ nil
61
77
  end
62
78
 
63
79
  def error_message
64
- params_root_node['error']['errorMessage'] rescue nil
80
+ params_root_node["error"]["errorMessage"]
81
+ rescue
82
+ nil
65
83
  end
66
84
 
67
85
  def error_detail
68
- params_root_node['error']['errorDetail'] rescue nil
86
+ params_root_node["error"]["errorDetail"]
87
+ rescue
88
+ nil
69
89
  end
70
90
 
71
91
  private
72
92
 
73
93
  def params_root_node
74
- params['authorizationService']['body']['transaction']
94
+ params["authorizationService"]["body"]["transaction"]
75
95
  end
76
96
  end
77
- end
97
+ end
@@ -1,12 +1,12 @@
1
- require 'datatrans/xml/transaction/request'
2
- require 'datatrans/xml/transaction/response'
1
+ require "datatrans/xml/transaction/request"
2
+ require "datatrans/xml/transaction/response"
3
3
 
4
4
  class Datatrans::XML::Transaction
5
5
  class CaptureRequest < Request
6
6
  def process
7
- post(self.datatrans.url(:xml_settlement_url),
8
- :headers => { 'Content-Type' => 'text/xml' },
9
- :body => build_capture_request.to_s).parsed_response
7
+ post(datatrans.url(:xml_settlement_url),
8
+ headers: {"Content-Type" => "text/xml"},
9
+ body: build_capture_request.to_s).parsed_response
10
10
  end
11
11
 
12
12
  private
@@ -22,41 +22,55 @@ class Datatrans::XML::Transaction
22
22
 
23
23
  class CaptureResponse < Response
24
24
  def successful?
25
- response_code == '01' && response_message == 'settlement succeeded'
25
+ response_code == "01" && response_message == "settlement succeeded"
26
26
  end
27
27
 
28
28
  def response_code
29
- params_root_node['response']['responseCode'] rescue nil
29
+ params_root_node["response"]["responseCode"]
30
+ rescue
31
+ nil
30
32
  end
31
33
 
32
34
  def response_message
33
- params_root_node['response']['responseMessage'] rescue nil
35
+ params_root_node["response"]["responseMessage"]
36
+ rescue
37
+ nil
34
38
  end
35
39
 
36
40
  def transaction_id
37
- params_root_node['request']['uppTransactionId'] rescue nil
41
+ params_root_node["request"]["uppTransactionId"]
42
+ rescue
43
+ nil
38
44
  end
39
45
 
40
46
  def reference_number
41
- params_root_node['refno'] rescue nil
47
+ params_root_node["refno"]
48
+ rescue
49
+ nil
42
50
  end
43
51
 
44
52
  def error_code
45
- params_root_node['error']['errorCode'] rescue nil
53
+ params_root_node["error"]["errorCode"]
54
+ rescue
55
+ nil
46
56
  end
47
57
 
48
58
  def error_message
49
- params_root_node['error']['errorMessage'] rescue nil
59
+ params_root_node["error"]["errorMessage"]
60
+ rescue
61
+ nil
50
62
  end
51
63
 
52
64
  def error_detail
53
- params_root_node['error']['errorDetail'] rescue nil
65
+ params_root_node["error"]["errorDetail"]
66
+ rescue
67
+ nil
54
68
  end
55
69
 
56
70
  private
57
71
 
58
72
  def params_root_node
59
- params['paymentService']['body']['transaction']
73
+ params["paymentService"]["body"]["transaction"]
60
74
  end
61
75
  end
62
- end
76
+ end
@@ -1,25 +1,26 @@
1
- require 'httparty'
2
- require 'builder'
1
+ require "httparty"
2
+ require "builder"
3
3
 
4
4
  class Datatrans::XML::Transaction
5
5
  class Request
6
-
7
6
  attr_accessor :params, :datatrans
8
7
 
9
8
  def post(url, options = {})
10
9
  options = options
11
- .merge(self.datatrans.proxy)
12
- .merge(:basic_auth => { :username => self.datatrans.merchant_id, :password => self.datatrans.password })
10
+ .merge(datatrans.proxy)
11
+ .merge(basic_auth: {username: datatrans.merchant_id, password: datatrans.password})
13
12
  HTTParty.post(url, **options)
14
13
  end
15
14
 
16
15
  def initialize(datatrans, params)
16
+ warn "DEPRECATION WARNING: Support for the XML API is deprecated and will be removed in the next major version. Please use the JSON API instead."
17
+
17
18
  @datatrans = datatrans
18
19
  @params = params
19
20
  end
20
21
 
21
22
  def process
22
- raise 'overwrite in subclass!'
23
+ raise "overwrite in subclass!"
23
24
  end
24
25
 
25
26
  private
@@ -29,9 +30,9 @@ class Datatrans::XML::Transaction
29
30
  def build_xml_request(service)
30
31
  xml = Builder::XmlMarkup.new
31
32
  xml.instruct!
32
- xml.tag! "#{service}Service", :version => 1 do
33
- xml.body :merchantId => self.datatrans.merchant_id do |body|
34
- xml.transaction :refno => params[:refno] do
33
+ xml.tag! "#{service}Service", version: 1 do
34
+ xml.body merchantId: datatrans.merchant_id do |body|
35
+ xml.transaction refno: params[:refno] do
35
36
  xml.request do
36
37
  yield body
37
38
  end
@@ -3,12 +3,14 @@ class Datatrans::XML::Transaction
3
3
  attr_reader :params, :datatrans
4
4
 
5
5
  def initialize(datatrans, params)
6
+ warn "DEPRECATION WARNING: Support for the XML API is deprecated and will be removed in the next major version. Please use the JSON API instead."
7
+
6
8
  @datatrans = datatrans
7
9
  @params = params
8
10
  end
9
11
 
10
12
  def successful?
11
- raise 'overwrite in subclass!'
13
+ raise "overwrite in subclass!"
12
14
  end
13
15
  end
14
- end
16
+ end
@@ -1,15 +1,15 @@
1
- require 'datatrans/xml/transaction/request'
2
- require 'datatrans/xml/transaction/response'
1
+ require "datatrans/xml/transaction/request"
2
+ require "datatrans/xml/transaction/response"
3
3
 
4
4
  class Datatrans::XML::Transaction
5
5
  class StatusRequest < Request
6
6
  def process
7
7
  post(
8
- self.datatrans.url(:xml_status_url),
9
- :headers => {
10
- 'Content-Type' => 'text/xml'
8
+ datatrans.url(:xml_status_url),
9
+ headers: {
10
+ "Content-Type" => "text/xml"
11
11
  },
12
- :body => build_status_request.to_s
12
+ body: build_status_request.to_s
13
13
  ).parsed_response
14
14
  end
15
15
 
@@ -25,60 +25,76 @@ class Datatrans::XML::Transaction
25
25
  class StatusResponse < Response
26
26
  def successful?
27
27
  [
28
- '1', # Transaction ready for settlement (trx authorized)
29
- '2', # Transaction debit waiting for daily settlement process
30
- '3', # Transaction credit waiting for daily settlement process
28
+ "1", # Transaction ready for settlement (trx authorized)
29
+ "2", # Transaction debit waiting for daily settlement process
30
+ "3" # Transaction credit waiting for daily settlement process
31
31
  ].include?(response_code)
32
32
  end
33
33
 
34
34
  def response_code
35
- params_root_node['response']['responseCode'] rescue nil
35
+ params_root_node["response"]["responseCode"]
36
+ rescue
37
+ nil
36
38
  end
37
39
 
38
40
  def response_message
39
- params_root_node['response']['responseMessage'] rescue nil
41
+ params_root_node["response"]["responseMessage"]
42
+ rescue
43
+ nil
40
44
  end
41
45
 
42
46
  def error_code
43
- params_root_node['error']['errorCode'] rescue nil
47
+ params_root_node["error"]["errorCode"]
48
+ rescue
49
+ nil
44
50
  end
45
51
 
46
52
  def error_message
47
- params_root_node['error']['errorMessage'] rescue nil
53
+ params_root_node["error"]["errorMessage"]
54
+ rescue
55
+ nil
48
56
  end
49
57
 
50
58
  def error_detail
51
- params_root_node['error']['errorDetail'] rescue nil
59
+ params_root_node["error"]["errorDetail"]
60
+ rescue
61
+ nil
52
62
  end
53
63
 
54
64
  def reference_number
55
- params_root_node['response']['refno'] rescue nil
65
+ params_root_node["response"]["refno"]
66
+ rescue
67
+ nil
56
68
  end
57
69
 
58
70
  def amount
59
- params_root_node['response']['amount'] rescue nil
71
+ params_root_node["response"]["amount"]
72
+ rescue
73
+ nil
60
74
  end
61
75
 
62
76
  def currency
63
- params_root_node['response']['currency'] rescue nil
77
+ params_root_node["response"]["currency"]
78
+ rescue
79
+ nil
64
80
  end
65
81
 
66
82
  def authorization_code
67
- params_root_node['response']['authorizationCode'] rescue nil
68
- end
69
-
70
- def authorization_code
71
- params_root_node['response']['authorizationCode'] rescue nil
83
+ params_root_node["response"]["authorizationCode"]
84
+ rescue
85
+ nil
72
86
  end
73
87
 
74
88
  def payment_method
75
- params_root_node['response']['pmethod'] rescue nil
89
+ params_root_node["response"]["pmethod"]
90
+ rescue
91
+ nil
76
92
  end
77
93
 
78
94
  private
79
95
 
80
96
  def params_root_node
81
- params['statusService']['body']['transaction']
97
+ params["statusService"]["body"]["transaction"]
82
98
  end
83
99
  end
84
- end
100
+ end
@@ -1,12 +1,12 @@
1
- require 'datatrans/xml/transaction/request'
2
- require 'datatrans/xml/transaction/response'
1
+ require "datatrans/xml/transaction/request"
2
+ require "datatrans/xml/transaction/response"
3
3
 
4
4
  class Datatrans::XML::Transaction
5
5
  class VoidRequest < Request
6
6
  def process
7
- post(self.datatrans.url(:xml_settlement_url),
8
- :headers => { 'Content-Type' => 'text/xml' },
9
- :body => build_void_request.to_s).parsed_response
7
+ post(datatrans.url(:xml_settlement_url),
8
+ headers: {"Content-Type" => "text/xml"},
9
+ body: build_void_request.to_s).parsed_response
10
10
  end
11
11
 
12
12
  private
@@ -16,48 +16,62 @@ class Datatrans::XML::Transaction
16
16
  xml.amount params[:amount]
17
17
  xml.currency params[:currency]
18
18
  xml.uppTransactionId params[:transaction_id]
19
- xml.reqtype 'DOA'
19
+ xml.reqtype "DOA"
20
20
  end
21
21
  end
22
22
  end
23
23
 
24
24
  class VoidResponse < Response
25
25
  def successful?
26
- response_code == '01' && response_message == 'cancellation succeeded'
26
+ response_code == "01" && response_message == "cancellation succeeded"
27
27
  end
28
28
 
29
29
  def response_code
30
- params_root_node['response']['responseCode'] rescue nil
30
+ params_root_node["response"]["responseCode"]
31
+ rescue
32
+ nil
31
33
  end
32
34
 
33
35
  def response_message
34
- params_root_node['response']['responseMessage'] rescue nil
36
+ params_root_node["response"]["responseMessage"]
37
+ rescue
38
+ nil
35
39
  end
36
40
 
37
41
  def transaction_id
38
- params_root_node['request']['uppTransactionId'] rescue nil
42
+ params_root_node["request"]["uppTransactionId"]
43
+ rescue
44
+ nil
39
45
  end
40
46
 
41
47
  def reference_number
42
- params_root_node['refno'] rescue nil
48
+ params_root_node["refno"]
49
+ rescue
50
+ nil
43
51
  end
44
52
 
45
53
  def error_code
46
- params_root_node['error']['errorCode'] rescue nil
54
+ params_root_node["error"]["errorCode"]
55
+ rescue
56
+ nil
47
57
  end
48
58
 
49
59
  def error_message
50
- params_root_node['error']['errorMessage'] rescue nil
60
+ params_root_node["error"]["errorMessage"]
61
+ rescue
62
+ nil
51
63
  end
52
64
 
53
65
  def error_detail
54
- params_root_node['error']['errorDetail'] rescue nil
66
+ params_root_node["error"]["errorDetail"]
67
+ rescue
68
+ nil
55
69
  end
56
70
 
57
71
  private
58
72
 
59
73
  def params_root_node
60
- params['paymentService']['body']['transaction']
74
+ params["paymentService"]["body"]["transaction"]
61
75
  end
62
76
  end
63
- end
77
+ end
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/hash'
1
+ require "active_support/core_ext/hash"
2
2
 
3
3
  module Datatrans::XML
4
4
  class Transaction
@@ -6,36 +6,41 @@ module Datatrans::XML
6
6
  attr_reader :response, :params, :datatrans
7
7
 
8
8
  def initialize(datatrans, params)
9
+ warn "DEPRECATION WARNING: Support for the XML API is deprecated and will be removed in the next major version. Please use the JSON API instead."
10
+
9
11
  @datatrans = datatrans
10
12
  @params = params.symbolize_keys
11
13
  end
12
14
 
13
15
  def authorize
14
- self.request = AuthorizeRequest.new(self.datatrans, params)
15
- @response = AuthorizeResponse.new(self.datatrans, request.process)
16
+ self.request = AuthorizeRequest.new(datatrans, params)
17
+ @response = AuthorizeResponse.new(datatrans, request.process)
16
18
  @response.successful?
17
19
  end
18
20
 
19
21
  def void
20
- self.request = VoidRequest.new(self.datatrans, params)
21
- @response = VoidResponse.new(self.datatrans, request.process)
22
+ self.request = VoidRequest.new(datatrans, params)
23
+ @response = VoidResponse.new(datatrans, request.process)
22
24
  @response.successful?
23
25
  end
24
26
 
25
27
  def capture
26
- self.request = CaptureRequest.new(self.datatrans, params)
27
- @response = CaptureResponse.new(self.datatrans, request.process)
28
+ self.request = CaptureRequest.new(datatrans, params)
29
+ @response = CaptureResponse.new(datatrans, request.process)
28
30
  @response.successful?
29
31
  end
30
32
 
31
33
  def status
32
- self.request = StatusRequest.new(self.datatrans, params)
33
- @response = StatusResponse.new(self.datatrans, request.process)
34
+ self.request = StatusRequest.new(datatrans, params)
35
+ @response = StatusResponse.new(datatrans, request.process)
34
36
  @response.successful?
35
37
  end
36
38
 
37
39
  # TODO: purchase, credit methods
38
40
 
41
+ def respond_to_missing?(method, *)
42
+ response.respond_to?(method.to_sym) || request.respond_to?(method.to_sym) || super
43
+ end
39
44
 
40
45
  def method_missing(method, *args, &block)
41
46
  if response.respond_to? method.to_sym
@@ -49,8 +54,7 @@ module Datatrans::XML
49
54
  end
50
55
  end
51
56
 
52
- require 'datatrans/xml/transaction/authorize'
53
- require 'datatrans/xml/transaction/void'
54
- require 'datatrans/xml/transaction/capture'
55
- require 'datatrans/xml/transaction/status'
56
-
57
+ require "datatrans/xml/transaction/authorize"
58
+ require "datatrans/xml/transaction/void"
59
+ require "datatrans/xml/transaction/capture"
60
+ require "datatrans/xml/transaction/status"
data/lib/datatrans.rb CHANGED
@@ -1,18 +1,19 @@
1
- require 'active_support/core_ext/module'
1
+ require "active_support/core_ext/module"
2
2
 
3
3
  module Datatrans
4
4
  InvalidSignatureError = Class.new(StandardError)
5
5
  end
6
6
 
7
- require 'datatrans/version'
8
- require 'datatrans/common'
9
- require 'datatrans/config'
10
- require 'datatrans/xml/transaction'
11
- require 'datatrans/web/transaction'
7
+ require "datatrans/version"
8
+ require "datatrans/common"
9
+ require "datatrans/config"
10
+ require "datatrans/xml/transaction"
11
+ require "datatrans/web/transaction"
12
+ require "datatrans/json/transaction"
12
13
 
13
14
  begin
14
- require 'action_view'
15
- require 'datatrans/web/view_helper'
15
+ require "action_view"
16
+ require "datatrans/web/view_helper"
16
17
  ActionView::Base.send(:include, Datatrans::Web::ViewHelper)
17
18
  rescue LoadError
18
19
  end
data/renovate.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "github>simplificator/renovate-preset"
5
+ ],
6
+ "packageRules": [
7
+ {
8
+ "matchPackagePatterns": [
9
+ "ruby"
10
+ ],
11
+ "enabled": false
12
+ }
13
+ ]
14
+ }
data/spec/common_spec.rb CHANGED
@@ -1,20 +1,20 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Datatrans::Common do
4
4
  context "sign" do
5
5
  before do
6
- #class Request
6
+ # class Request
7
7
  # include Datatrans::Common
8
- #end
8
+ # end
9
9
  @request = Datatrans::XML::Transaction::Request.new(@datatrans, {})
10
10
  end
11
11
 
12
12
  it "generates the correct sign" do
13
13
  amount = 1000
14
- currency = 'CHF'
15
- reference_number = 'ABCEDF'
14
+ currency = "CHF"
15
+ reference_number = "ABCEDF"
16
16
 
17
- expect(@request.sign(@datatrans.merchant_id, amount, currency, reference_number)).to eq '4e7d4d5bbde548c586f3b7f109635ffc'
17
+ expect(@request.sign(@datatrans.merchant_id, amount, currency, reference_number)).to eq "4e7d4d5bbde548c586f3b7f109635ffc"
18
18
  end
19
19
  end
20
20
  end
data/spec/config_spec.rb CHANGED
@@ -1,9 +1,9 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
3
  describe Datatrans::Config do
4
4
  describe "Instance Methods" do
5
5
  before do
6
- @datatrans = Datatrans::Config.new(:merchant_id => "xxx", :password => "yyy")
6
+ @datatrans = Datatrans::Config.new(merchant_id: "xxx", password: "yyy")
7
7
  end
8
8
 
9
9
  describe "web_transaction" do
@@ -17,5 +17,11 @@ describe Datatrans::Config do
17
17
  expect(@datatrans.xml_transaction({}).class).to eq(Datatrans::XML::Transaction)
18
18
  end
19
19
  end
20
+
21
+ describe "json_transaction" do
22
+ it "builds a new json transaction object" do
23
+ expect(@datatrans.json_transaction({}).class).to eq(Datatrans::JSON::Transaction)
24
+ end
25
+ end
20
26
  end
21
27
  end