diff --git a/Rakefile b/Rakefile
index 592167d..6c4c659 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,5 +1,5 @@
-require 'bundler/gem_tasks'
+require "bundler/gem_tasks"
require "rspec/core/rake_task"
RSpec::Core::RakeTask.new("spec")
-task :default => :spec
+task default: :spec
diff --git a/datatrans.gemspec b/datatrans.gemspec
index 3c253ac..67e1785 100644
--- a/datatrans.gemspec
+++ b/datatrans.gemspec
@@ -1,34 +1,32 @@
-# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "datatrans/version"
Gem::Specification.new do |s|
- s.name = "datatrans"
- s.version = Datatrans::VERSION
- s.authors = ["Tobias Miesel", "Thomas Maurer", "Corin Langosch", "Pascal Betz"]
- s.email = ["info@simplificator.com"]
- s.homepage = ""
- s.summary = %q{Datatrans Integration for Ruby on Rails}
- s.description = %q{Datatrans Integration for Ruby on Rails}
+ s.name = "datatrans"
+ s.version = Datatrans::VERSION
+ s.authors = ["Tobias Miesel", "Thomas Maurer", "Corin Langosch", "Pascal Betz"]
+ s.email = ["info@simplificator.com"]
+ s.homepage = ""
+ s.summary = "Datatrans Integration for Ruby on Rails"
+ s.description = "Datatrans Integration for Ruby on Rails"
s.rubyforge_project = "datatrans"
- s.files = `git ls-files`.split("\n")
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.files = `git ls-files`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
s.require_paths = ["lib"]
- s.required_ruby_version = '>= 2.6'
+ s.required_ruby_version = ">= 2.6"
- s.add_dependency 'httparty'
- s.add_dependency 'activesupport', '>= 5.2'
- s.add_dependency 'i18n'
- s.add_dependency 'builder'
- s.add_dependency 'multi_xml', '>= 0.5.1'
+ s.add_dependency "httparty"
+ s.add_dependency "activesupport", ">= 5.2"
+ s.add_dependency "i18n"
+ s.add_dependency "builder"
+ s.add_dependency "multi_xml", ">= 0.5.1"
- s.add_development_dependency 'actionpack', '>= 5.2'
- s.add_development_dependency 'appraisal'
- s.add_development_dependency 'rake'
- s.add_development_dependency 'rspec'
- s.license = 'MIT'
+ s.add_development_dependency "actionpack", ">= 5.2"
+ s.add_development_dependency "appraisal"
+ s.add_development_dependency "rake"
+ s.add_development_dependency "rspec"
+ s.license = "MIT"
end
diff --git a/lib/datatrans.rb b/lib/datatrans.rb
index b9d8d9c..824786b 100644
--- a/lib/datatrans.rb
+++ b/lib/datatrans.rb
@@ -1,19 +1,19 @@
-require 'active_support/core_ext/module'
+require "active_support/core_ext/module"
module Datatrans
InvalidSignatureError = Class.new(StandardError)
end
-require 'datatrans/version'
-require 'datatrans/common'
-require 'datatrans/config'
-require 'datatrans/xml/transaction'
-require 'datatrans/web/transaction'
-require 'datatrans/json/transaction'
+require "datatrans/version"
+require "datatrans/common"
+require "datatrans/config"
+require "datatrans/xml/transaction"
+require "datatrans/web/transaction"
+require "datatrans/json/transaction"
begin
- require 'action_view'
- require 'datatrans/web/view_helper'
+ require "action_view"
+ require "datatrans/web/view_helper"
ActionView::Base.send(:include, Datatrans::Web::ViewHelper)
rescue LoadError
end
diff --git a/lib/datatrans/common.rb b/lib/datatrans/common.rb
index 9de4cd1..c62cf18 100644
--- a/lib/datatrans/common.rb
+++ b/lib/datatrans/common.rb
@@ -1,10 +1,10 @@
-require 'openssl'
+require "openssl"
module Datatrans::Common
def sign(*fields)
- return nil unless self.datatrans.sign_key
- key = self.datatrans.sign_key.split(/([a-f0-9][a-f0-9])/).reject(&:empty?)
+ return nil unless datatrans.sign_key
+ key = datatrans.sign_key.split(/([a-f0-9][a-f0-9])/).reject(&:empty?)
key = key.pack("H*" * key.size)
- OpenSSL::HMAC.hexdigest(OpenSSL::Digest::MD5.new, key, fields.join)
+ OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("MD5"), key, fields.join)
end
-end
\ No newline at end of file
+end
diff --git a/lib/datatrans/config.rb b/lib/datatrans/config.rb
index 101a66e..b945791 100644
--- a/lib/datatrans/config.rb
+++ b/lib/datatrans/config.rb
@@ -6,10 +6,10 @@ class Config
DEFAULT_SIGN_KEY = false
SUBDOMAINS = {
- payment_page: 'pay',
- server_to_server_api: 'api'
+ payment_page: "pay",
+ server_to_server_api: "api"
}
- DOMAIN = 'datatrans.com'
+ DOMAIN = "datatrans.com"
attr_reader :environment, :merchant_id, :sign_key, :password, :proxy
@@ -21,10 +21,10 @@ class Config
# * :proxy (a hash containing :http_proxyaddr, :http_proxyport, :http_proxyuser, :http_proxypass)
def initialize(options = {})
@merchant_id = options[:merchant_id]
- raise ArgumentError.new(":merchant_id is required") unless self.merchant_id
+ raise ArgumentError.new(":merchant_id is required") unless merchant_id
self.environment = options[:environment] || DEFAULT_ENVIRONMENT
@password = options[:password]
- raise ArgumentError.new(":password is required") unless self.password
+ raise ArgumentError.new(":password is required") unless password
@sign_key = options[:sign_key] || DEFAULT_SIGN_KEY
@proxy = options[:proxy] || {}
end
@@ -34,7 +34,7 @@ def environment=(environment)
if ENVIRONMENTS.include?(environment)
@environment = environment
else
- raise "Unknown environment '#{environment}'. Available: #{ENVIRONMENTS.join(', ')}"
+ raise "Unknown environment '#{environment}'. Available: #{ENVIRONMENTS.join(", ")}"
end
end
@@ -43,16 +43,16 @@ def url(what, options = {})
case what
when :web_authorize_url
subdomain = SUBDOMAINS[:payment_page]
- path = '/upp/jsp/upStart.jsp'
+ path = "/upp/jsp/upStart.jsp"
when :xml_authorize_url
subdomain = SUBDOMAINS[:server_to_server_api]
- path = '/upp/jsp/XML_authorize.jsp'
+ path = "/upp/jsp/XML_authorize.jsp"
when :xml_settlement_url
subdomain = SUBDOMAINS[:server_to_server_api]
- path = '/upp/jsp/XML_processor.jsp'
+ path = "/upp/jsp/XML_processor.jsp"
when :xml_status_url
subdomain = SUBDOMAINS[:server_to_server_api]
- path = '/upp/jsp/XML_status.jsp'
+ path = "/upp/jsp/XML_status.jsp"
when :init_transaction
subdomain = SUBDOMAINS[:server_to_server_api]
path = "/v1/transactions"
@@ -73,7 +73,7 @@ def url(what, options = {})
else
raise "Unknown wanted action '#{what}'."
end
- subdomain += '.sandbox' unless self.environment == :production
+ subdomain += ".sandbox" unless environment == :production
"https://#{subdomain}.#{DOMAIN}#{path}"
end
diff --git a/lib/datatrans/json/transaction.rb b/lib/datatrans/json/transaction.rb
index d021032..3f40ca5 100644
--- a/lib/datatrans/json/transaction.rb
+++ b/lib/datatrans/json/transaction.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/hash'
+require "active_support/core_ext/hash"
module Datatrans::JSON
class Transaction
@@ -11,36 +11,36 @@ def initialize(datatrans, params)
end
def authorize
- self.request = Authorize.new(self.datatrans, params)
- @response = AuthorizeResponse.new(self.datatrans, request.process)
+ self.request = Authorize.new(datatrans, params)
+ @response = AuthorizeResponse.new(datatrans, request.process)
@response.successful?
end
def merchant_authorize
- self.request = MerchantAuthorize.new(self.datatrans, params)
- @response = MerchantAuthorizeResponse.new(self.datatrans, request.process)
+ self.request = MerchantAuthorize.new(datatrans, params)
+ @response = MerchantAuthorizeResponse.new(datatrans, request.process)
@response.successful?
end
def status
- self.request = Status.new(self.datatrans, params)
- @response = StatusResponse.new(self.datatrans, request.process)
+ self.request = Status.new(datatrans, params)
+ @response = StatusResponse.new(datatrans, request.process)
@response.successful?
end
def settle
- self.request = Settle.new(self.datatrans, params)
- @response = SettleResponse.new(self.datatrans, request.process)
+ self.request = Settle.new(datatrans, params)
+ @response = SettleResponse.new(datatrans, request.process)
@response.successful?
end
def transaction_path
- self.datatrans.url(:start_json_transaction, transaction_id: params[:transaction_id])
+ datatrans.url(:start_json_transaction, transaction_id: params[:transaction_id])
end
end
end
-require 'datatrans/json/transaction/authorize'
-require 'datatrans/json/transaction/merchant_authorize'
-require 'datatrans/json/transaction/status'
-require 'datatrans/json/transaction/settle'
+require "datatrans/json/transaction/authorize"
+require "datatrans/json/transaction/merchant_authorize"
+require "datatrans/json/transaction/status"
+require "datatrans/json/transaction/settle"
diff --git a/lib/datatrans/json/transaction/authorize.rb b/lib/datatrans/json/transaction/authorize.rb
index f7c236c..961725f 100644
--- a/lib/datatrans/json/transaction/authorize.rb
+++ b/lib/datatrans/json/transaction/authorize.rb
@@ -1,5 +1,5 @@
-require 'httparty'
-require 'datatrans/json/transaction/response'
+require "httparty"
+require "datatrans/json/transaction/response"
class Datatrans::JSON::Transaction
class Authorize
@@ -13,30 +13,30 @@ def initialize(datatrans, params)
def post(url, options = {})
options = options
- .merge(self.datatrans.proxy)
- .merge(:basic_auth => { :username => self.datatrans.merchant_id, :password => self.datatrans.password })
+ .merge(datatrans.proxy)
+ .merge(basic_auth: {username: datatrans.merchant_id, password: datatrans.password})
HTTParty.post(url, **options)
end
def process
- post(self.datatrans.url(:init_transaction),
- :headers => { 'Content-Type' => 'application/json' },
- :body => request_body.to_json).parsed_response
+ post(datatrans.url(:init_transaction),
+ headers: {"Content-Type" => "application/json"},
+ body: request_body.to_json).parsed_response
end
def request_body
auto_settle = params[:auto_settle].nil? ? true : params[:auto_settle]
body = {
- "currency": params[:currency],
- "refno": params[:refno],
- "amount": params[:amount],
- "autoSettle": auto_settle,
- "paymentMethods": params[:payment_methods],
- "redirect": {
- "successUrl": params[:success_url],
- "cancelUrl": params[:cancel_url],
- "errorUrl": params[:error_url]
+ currency: params[:currency],
+ refno: params[:refno],
+ amount: params[:amount],
+ autoSettle: auto_settle,
+ paymentMethods: params[:payment_methods],
+ redirect: {
+ successUrl: params[:success_url],
+ cancelUrl: params[:cancel_url],
+ errorUrl: params[:error_url]
}
}
diff --git a/lib/datatrans/json/transaction/merchant_authorize.rb b/lib/datatrans/json/transaction/merchant_authorize.rb
index b28bc9d..8488325 100644
--- a/lib/datatrans/json/transaction/merchant_authorize.rb
+++ b/lib/datatrans/json/transaction/merchant_authorize.rb
@@ -1,5 +1,5 @@
-require 'httparty'
-require 'datatrans/json/transaction/response'
+require "httparty"
+require "datatrans/json/transaction/response"
class Datatrans::JSON::Transaction
class MerchantAuthorize
@@ -13,26 +13,26 @@ def initialize(datatrans, params)
def post(url, options = {})
options = options
- .merge(self.datatrans.proxy)
- .merge(:basic_auth => { :username => self.datatrans.merchant_id, :password => self.datatrans.password })
+ .merge(datatrans.proxy)
+ .merge(basic_auth: {username: datatrans.merchant_id, password: datatrans.password})
HTTParty.post(url, **options)
end
def process
- post(self.datatrans.url(:authorize_transaction),
- :headers => { 'Content-Type' => 'application/json' },
- :body => request_body.to_json).parsed_response
+ post(datatrans.url(:authorize_transaction),
+ headers: {"Content-Type" => "application/json"},
+ body: request_body.to_json).parsed_response
end
def request_body
auto_settle = params[:auto_settle].nil? ? true : params[:auto_settle]
{
- "currency": params[:currency],
- "refno": params[:refno],
- "amount": params[:amount],
- "card": params[:card],
- "autoSettle": auto_settle,
+ currency: params[:currency],
+ refno: params[:refno],
+ amount: params[:amount],
+ card: params[:card],
+ autoSettle: auto_settle
}
end
end
diff --git a/lib/datatrans/json/transaction/response.rb b/lib/datatrans/json/transaction/response.rb
index 7a94cb6..8a0b970 100644
--- a/lib/datatrans/json/transaction/response.rb
+++ b/lib/datatrans/json/transaction/response.rb
@@ -8,15 +8,19 @@ def initialize(datatrans, params)
end
def successful?
- raise 'overwrite in subclass!'
+ raise "overwrite in subclass!"
end
def error_code
- params["error"]["code"] rescue nil
+ params["error"]["code"]
+ rescue
+ nil
end
def error_message
- params["error"]["message"] rescue nil
+ params["error"]["message"]
+ rescue
+ nil
end
end
end
diff --git a/lib/datatrans/json/transaction/settle.rb b/lib/datatrans/json/transaction/settle.rb
index f9b9b7a..6889996 100644
--- a/lib/datatrans/json/transaction/settle.rb
+++ b/lib/datatrans/json/transaction/settle.rb
@@ -1,5 +1,5 @@
-require 'httparty'
-require 'datatrans/json/transaction/response'
+require "httparty"
+require "datatrans/json/transaction/response"
class Datatrans::JSON::Transaction
class Settle
@@ -13,22 +13,22 @@ def initialize(datatrans, params)
def post(url, options = {})
options = options
- .merge(self.datatrans.proxy)
- .merge(:basic_auth => { :username => self.datatrans.merchant_id, :password => self.datatrans.password })
+ .merge(datatrans.proxy)
+ .merge(basic_auth: {username: datatrans.merchant_id, password: datatrans.password})
HTTParty.post(url, **options)
end
def process
- post(self.datatrans.url(:json_settle_url, transaction_id: params[:transaction_id]),
- :headers => { 'Content-Type' => 'application/json' },
- :body => request_body.to_json).parsed_response
+ post(datatrans.url(:json_settle_url, transaction_id: params[:transaction_id]),
+ headers: {"Content-Type" => "application/json"},
+ body: request_body.to_json).parsed_response
end
def request_body
{
- "currency": params[:currency],
- "amount": params[:amount],
- "refno": params[:refno]
+ currency: params[:currency],
+ amount: params[:amount],
+ refno: params[:refno]
}
end
end
diff --git a/lib/datatrans/json/transaction/status.rb b/lib/datatrans/json/transaction/status.rb
index f611c9f..bda8d02 100644
--- a/lib/datatrans/json/transaction/status.rb
+++ b/lib/datatrans/json/transaction/status.rb
@@ -1,5 +1,5 @@
-require 'httparty'
-require 'datatrans/json/transaction/response'
+require "httparty"
+require "datatrans/json/transaction/response"
class Datatrans::JSON::Transaction
class Status
@@ -13,14 +13,14 @@ def initialize(datatrans, params)
def get(url, options = {})
options = options
- .merge(self.datatrans.proxy)
- .merge(:basic_auth => { :username => self.datatrans.merchant_id, :password => self.datatrans.password })
+ .merge(datatrans.proxy)
+ .merge(basic_auth: {username: datatrans.merchant_id, password: datatrans.password})
HTTParty.get(url, **options)
end
def process
- get(self.datatrans.url(:json_status_url, transaction_id: params[:transaction_id]),
- :headers => { 'Content-Type' => 'application/json' }).parsed_response
+ get(datatrans.url(:json_status_url, transaction_id: params[:transaction_id]),
+ headers: {"Content-Type" => "application/json"}).parsed_response
end
end
@@ -30,15 +30,21 @@ def successful?
end
def response_code
- params["status"] rescue nil
+ params["status"]
+ rescue
+ nil
end
def reference_number
- params["refno"] rescue nil
+ params["refno"]
+ rescue
+ nil
end
def amount
- params["detail"]["settle"]["amount"] rescue nil
+ params["detail"]["settle"]["amount"]
+ rescue
+ nil
end
end
end
diff --git a/lib/datatrans/web/transaction.rb b/lib/datatrans/web/transaction.rb
index 6d4539a..7e45e78 100644
--- a/lib/datatrans/web/transaction.rb
+++ b/lib/datatrans/web/transaction.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/hash'
+require "active_support/core_ext/hash"
module Datatrans::Web
class Transaction
@@ -11,12 +11,12 @@ def initialize(datatrans, params)
@datatrans = datatrans
params = params.to_hash
params.symbolize_keys!
- params.reverse_merge!(:reqtype => 'NOA', :useAlias => 'yes', :hiddenMode => 'yes')
+ params.reverse_merge!(reqtype: "NOA", useAlias: "yes", hiddenMode: "yes")
@params = params
end
def signature
- sign(self.datatrans.merchant_id, params[:amount], params[:currency], params[:refno])
+ sign(datatrans.merchant_id, params[:amount], params[:currency], params[:refno])
end
def authorize
@@ -34,4 +34,4 @@ def method_missing(method, *args, &block)
end
end
-require 'datatrans/web/transaction/authorize'
+require "datatrans/web/transaction/authorize"
diff --git a/lib/datatrans/web/transaction/authorize.rb b/lib/datatrans/web/transaction/authorize.rb
index b50cb02..8014287 100644
--- a/lib/datatrans/web/transaction/authorize.rb
+++ b/lib/datatrans/web/transaction/authorize.rb
@@ -9,72 +9,99 @@ def initialize(datatrans, params)
def successful?
raise Datatrans::InvalidSignatureError unless valid_signature?
- response_code == '01' && status == 'success' && !errors_occurred?
+ response_code == "01" && status == "success" && !errors_occurred?
end
def valid_signature?
# TODO: does not make sense... true if errors?
return true if errors_occurred? # no sign2 sent on error
- sign(self.datatrans.merchant_id, params[:amount], params[:currency], params[:uppTransactionId]) == params[:sign2]
+ sign(datatrans.merchant_id, params[:amount], params[:currency], params[:uppTransactionId]) == params[:sign2]
end
def status
- params[:status] rescue nil
+ params[:status]
+ rescue
+ nil
end
def response_code
- params[:responseCode] rescue nil
+ params[:responseCode]
+ rescue
+ nil
end
def response_message
- params[:responseMessage] rescue nil
+ params[:responseMessage]
+ rescue
+ nil
end
def transaction_id
- params[:uppTransactionId] rescue nil
+ params[:uppTransactionId]
+ rescue
+ nil
end
def reference_number
- params[:refno] rescue nil
+ params[:refno]
+ rescue
+ nil
end
def authorization_code
- params[:authorizationCode] rescue nil
+ params[:authorizationCode]
+ rescue
+ nil
end
def payment_method
- params[:pmethod] rescue nil
+ params[:pmethod]
+ rescue
+ nil
end
def masked_cc
- params[:maskedCC] rescue nil
+ params[:maskedCC]
+ rescue
+ nil
end
def exp_year
- params[:expy] rescue nil
+ params[:expy]
+ rescue
+ nil
end
def exp_month
- params[:expm] rescue nil
+ params[:expm]
+ rescue
+ nil
end
def creditcard_alias
- params[:aliasCC] rescue nil
+ params[:aliasCC]
+ rescue
+ nil
end
def error_code
- params[:errorCode] rescue nil
+ params[:errorCode]
+ rescue
+ nil
end
def error_message
- params[:errorMessage] rescue nil
+ params[:errorMessage]
+ rescue
+ nil
end
def error_detail
- params[:errorDetail] rescue nil
+ params[:errorDetail]
+ rescue
+ nil
end
-
private
def errors_occurred?
diff --git a/lib/datatrans/web/view_helper.rb b/lib/datatrans/web/view_helper.rb
index 1c0ea3e..cdcb45a 100644
--- a/lib/datatrans/web/view_helper.rb
+++ b/lib/datatrans/web/view_helper.rb
@@ -10,7 +10,7 @@ def datatrans_notification_request_hidden_fields(datatrans, transaction)
hidden_field_tag(:useAlias, transaction.params[:useAlias]),
hidden_field_tag(:sign, transaction.signature),
hidden_field_tag(:refno, transaction.params[:refno]),
- hidden_field_tag(:uppCustomerDetails, transaction.params[:uppCustomerDetails]),
+ hidden_field_tag(:uppCustomerDetails, transaction.params[:uppCustomerDetails])
]
[:uppCustomerName, :uppCustomerEmail].each do |field_name|
diff --git a/lib/datatrans/xml/transaction.rb b/lib/datatrans/xml/transaction.rb
index 2afb58b..fdf0ef9 100644
--- a/lib/datatrans/xml/transaction.rb
+++ b/lib/datatrans/xml/transaction.rb
@@ -1,4 +1,4 @@
-require 'active_support/core_ext/hash'
+require "active_support/core_ext/hash"
module Datatrans::XML
class Transaction
@@ -11,32 +11,31 @@ def initialize(datatrans, params)
end
def authorize
- self.request = AuthorizeRequest.new(self.datatrans, params)
- @response = AuthorizeResponse.new(self.datatrans, request.process)
+ self.request = AuthorizeRequest.new(datatrans, params)
+ @response = AuthorizeResponse.new(datatrans, request.process)
@response.successful?
end
def void
- self.request = VoidRequest.new(self.datatrans, params)
- @response = VoidResponse.new(self.datatrans, request.process)
+ self.request = VoidRequest.new(datatrans, params)
+ @response = VoidResponse.new(datatrans, request.process)
@response.successful?
end
def capture
- self.request = CaptureRequest.new(self.datatrans, params)
- @response = CaptureResponse.new(self.datatrans, request.process)
+ self.request = CaptureRequest.new(datatrans, params)
+ @response = CaptureResponse.new(datatrans, request.process)
@response.successful?
end
def status
- self.request = StatusRequest.new(self.datatrans, params)
- @response = StatusResponse.new(self.datatrans, request.process)
+ self.request = StatusRequest.new(datatrans, params)
+ @response = StatusResponse.new(datatrans, request.process)
@response.successful?
end
# TODO: purchase, credit methods
-
def method_missing(method, *args, &block)
if response.respond_to? method.to_sym
response.send(method)
@@ -49,8 +48,7 @@ def method_missing(method, *args, &block)
end
end
-require 'datatrans/xml/transaction/authorize'
-require 'datatrans/xml/transaction/void'
-require 'datatrans/xml/transaction/capture'
-require 'datatrans/xml/transaction/status'
-
+require "datatrans/xml/transaction/authorize"
+require "datatrans/xml/transaction/void"
+require "datatrans/xml/transaction/capture"
+require "datatrans/xml/transaction/status"
diff --git a/lib/datatrans/xml/transaction/authorize.rb b/lib/datatrans/xml/transaction/authorize.rb
index 56f690b..b2b46eb 100644
--- a/lib/datatrans/xml/transaction/authorize.rb
+++ b/lib/datatrans/xml/transaction/authorize.rb
@@ -1,12 +1,12 @@
-require 'datatrans/xml/transaction/request'
-require 'datatrans/xml/transaction/response'
+require "datatrans/xml/transaction/request"
+require "datatrans/xml/transaction/response"
class Datatrans::XML::Transaction
class AuthorizeRequest < Request
def process
- post(self.datatrans.url(:xml_authorize_url),
- :headers => { 'Content-Type' => 'text/xml' },
- :body => build_authorize_request.to_s).parsed_response
+ post(datatrans.url(:xml_authorize_url),
+ headers: {"Content-Type" => "text/xml"},
+ body: build_authorize_request.to_s).parsed_response
end
private
@@ -18,60 +18,80 @@ def build_authorize_request
xml.aliasCC params[:aliasCC]
xml.expm params[:expm]
xml.expy params[:expy]
- xml.sign sign(self.datatrans.merchant_id, params[:amount], params[:currency], params[:refno])
+ xml.sign sign(datatrans.merchant_id, params[:amount], params[:currency], params[:refno])
end
end
end
class AuthorizeResponse < Response
def successful?
- response_code == '01' && response_message == 'Authorized'
+ response_code == "01" && response_message == "Authorized"
end
def response_code
- params_root_node['response']['responseCode'] rescue nil
+ params_root_node["response"]["responseCode"]
+ rescue
+ nil
end
def response_message
- params_root_node['response']['responseMessage'] rescue nil
+ params_root_node["response"]["responseMessage"]
+ rescue
+ nil
end
def transaction_id
- params_root_node['response']['uppTransactionId'] rescue nil
+ params_root_node["response"]["uppTransactionId"]
+ rescue
+ nil
end
def reference_number
- params_root_node['refno'] rescue nil
+ params_root_node["refno"]
+ rescue
+ nil
end
def authorization_code
- params_root_node['response']['authorizationCode'] rescue nil
+ params_root_node["response"]["authorizationCode"]
+ rescue
+ nil
end
def masked_cc
- params_root_node['response']['maskedCC'] rescue nil
+ params_root_node["response"]["maskedCC"]
+ rescue
+ nil
end
def creditcard_alias
- params_root_node['request']['aliasCC'] rescue nil
+ params_root_node["request"]["aliasCC"]
+ rescue
+ nil
end
def error_code
- params_root_node['error']['errorCode'] rescue nil
+ params_root_node["error"]["errorCode"]
+ rescue
+ nil
end
def error_message
- params_root_node['error']['errorMessage'] rescue nil
+ params_root_node["error"]["errorMessage"]
+ rescue
+ nil
end
def error_detail
- params_root_node['error']['errorDetail'] rescue nil
+ params_root_node["error"]["errorDetail"]
+ rescue
+ nil
end
private
def params_root_node
- params['authorizationService']['body']['transaction']
+ params["authorizationService"]["body"]["transaction"]
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/datatrans/xml/transaction/capture.rb b/lib/datatrans/xml/transaction/capture.rb
index b73228a..651c8fa 100644
--- a/lib/datatrans/xml/transaction/capture.rb
+++ b/lib/datatrans/xml/transaction/capture.rb
@@ -1,12 +1,12 @@
-require 'datatrans/xml/transaction/request'
-require 'datatrans/xml/transaction/response'
+require "datatrans/xml/transaction/request"
+require "datatrans/xml/transaction/response"
class Datatrans::XML::Transaction
class CaptureRequest < Request
def process
- post(self.datatrans.url(:xml_settlement_url),
- :headers => { 'Content-Type' => 'text/xml' },
- :body => build_capture_request.to_s).parsed_response
+ post(datatrans.url(:xml_settlement_url),
+ headers: {"Content-Type" => "text/xml"},
+ body: build_capture_request.to_s).parsed_response
end
private
@@ -22,41 +22,55 @@ def build_capture_request
class CaptureResponse < Response
def successful?
- response_code == '01' && response_message == 'settlement succeeded'
+ response_code == "01" && response_message == "settlement succeeded"
end
def response_code
- params_root_node['response']['responseCode'] rescue nil
+ params_root_node["response"]["responseCode"]
+ rescue
+ nil
end
def response_message
- params_root_node['response']['responseMessage'] rescue nil
+ params_root_node["response"]["responseMessage"]
+ rescue
+ nil
end
def transaction_id
- params_root_node['request']['uppTransactionId'] rescue nil
+ params_root_node["request"]["uppTransactionId"]
+ rescue
+ nil
end
def reference_number
- params_root_node['refno'] rescue nil
+ params_root_node["refno"]
+ rescue
+ nil
end
def error_code
- params_root_node['error']['errorCode'] rescue nil
+ params_root_node["error"]["errorCode"]
+ rescue
+ nil
end
def error_message
- params_root_node['error']['errorMessage'] rescue nil
+ params_root_node["error"]["errorMessage"]
+ rescue
+ nil
end
def error_detail
- params_root_node['error']['errorDetail'] rescue nil
+ params_root_node["error"]["errorDetail"]
+ rescue
+ nil
end
private
def params_root_node
- params['paymentService']['body']['transaction']
+ params["paymentService"]["body"]["transaction"]
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/datatrans/xml/transaction/request.rb b/lib/datatrans/xml/transaction/request.rb
index 6e3b992..f8b9875 100644
--- a/lib/datatrans/xml/transaction/request.rb
+++ b/lib/datatrans/xml/transaction/request.rb
@@ -1,15 +1,14 @@
-require 'httparty'
-require 'builder'
+require "httparty"
+require "builder"
class Datatrans::XML::Transaction
class Request
-
attr_accessor :params, :datatrans
def post(url, options = {})
options = options
- .merge(self.datatrans.proxy)
- .merge(:basic_auth => { :username => self.datatrans.merchant_id, :password => self.datatrans.password })
+ .merge(datatrans.proxy)
+ .merge(basic_auth: {username: datatrans.merchant_id, password: datatrans.password})
HTTParty.post(url, **options)
end
@@ -19,7 +18,7 @@ def initialize(datatrans, params)
end
def process
- raise 'overwrite in subclass!'
+ raise "overwrite in subclass!"
end
private
@@ -29,9 +28,9 @@ def process
def build_xml_request(service)
xml = Builder::XmlMarkup.new
xml.instruct!
- xml.tag! "#{service}Service", :version => 1 do
- xml.body :merchantId => self.datatrans.merchant_id do |body|
- xml.transaction :refno => params[:refno] do
+ xml.tag! "#{service}Service", version: 1 do
+ xml.body merchantId: datatrans.merchant_id do |body|
+ xml.transaction refno: params[:refno] do
xml.request do
yield body
end
diff --git a/lib/datatrans/xml/transaction/response.rb b/lib/datatrans/xml/transaction/response.rb
index 29bf2ab..e313b07 100644
--- a/lib/datatrans/xml/transaction/response.rb
+++ b/lib/datatrans/xml/transaction/response.rb
@@ -8,7 +8,7 @@ def initialize(datatrans, params)
end
def successful?
- raise 'overwrite in subclass!'
+ raise "overwrite in subclass!"
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/datatrans/xml/transaction/status.rb b/lib/datatrans/xml/transaction/status.rb
index b009f14..2aff4b1 100644
--- a/lib/datatrans/xml/transaction/status.rb
+++ b/lib/datatrans/xml/transaction/status.rb
@@ -1,15 +1,15 @@
-require 'datatrans/xml/transaction/request'
-require 'datatrans/xml/transaction/response'
+require "datatrans/xml/transaction/request"
+require "datatrans/xml/transaction/response"
class Datatrans::XML::Transaction
class StatusRequest < Request
def process
post(
- self.datatrans.url(:xml_status_url),
- :headers => {
- 'Content-Type' => 'text/xml'
+ datatrans.url(:xml_status_url),
+ headers: {
+ "Content-Type" => "text/xml"
},
- :body => build_status_request.to_s
+ body: build_status_request.to_s
).parsed_response
end
@@ -25,60 +25,82 @@ def build_status_request
class StatusResponse < Response
def successful?
[
- '1', # Transaction ready for settlement (trx authorized)
- '2', # Transaction debit waiting for daily settlement process
- '3', # Transaction credit waiting for daily settlement process
+ "1", # Transaction ready for settlement (trx authorized)
+ "2", # Transaction debit waiting for daily settlement process
+ "3" # Transaction credit waiting for daily settlement process
].include?(response_code)
end
def response_code
- params_root_node['response']['responseCode'] rescue nil
+ params_root_node["response"]["responseCode"]
+ rescue
+ nil
end
def response_message
- params_root_node['response']['responseMessage'] rescue nil
+ params_root_node["response"]["responseMessage"]
+ rescue
+ nil
end
def error_code
- params_root_node['error']['errorCode'] rescue nil
+ params_root_node["error"]["errorCode"]
+ rescue
+ nil
end
def error_message
- params_root_node['error']['errorMessage'] rescue nil
+ params_root_node["error"]["errorMessage"]
+ rescue
+ nil
end
def error_detail
- params_root_node['error']['errorDetail'] rescue nil
+ params_root_node["error"]["errorDetail"]
+ rescue
+ nil
end
def reference_number
- params_root_node['response']['refno'] rescue nil
+ params_root_node["response"]["refno"]
+ rescue
+ nil
end
def amount
- params_root_node['response']['amount'] rescue nil
+ params_root_node["response"]["amount"]
+ rescue
+ nil
end
def currency
- params_root_node['response']['currency'] rescue nil
+ params_root_node["response"]["currency"]
+ rescue
+ nil
end
def authorization_code
- params_root_node['response']['authorizationCode'] rescue nil
+ params_root_node["response"]["authorizationCode"]
+ rescue
+ nil
end
def authorization_code
- params_root_node['response']['authorizationCode'] rescue nil
+ params_root_node["response"]["authorizationCode"]
+ rescue
+ nil
end
def payment_method
- params_root_node['response']['pmethod'] rescue nil
+ params_root_node["response"]["pmethod"]
+ rescue
+ nil
end
private
def params_root_node
- params['statusService']['body']['transaction']
+ params["statusService"]["body"]["transaction"]
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/datatrans/xml/transaction/void.rb b/lib/datatrans/xml/transaction/void.rb
index 5c11ac8..14ce86e 100644
--- a/lib/datatrans/xml/transaction/void.rb
+++ b/lib/datatrans/xml/transaction/void.rb
@@ -1,12 +1,12 @@
-require 'datatrans/xml/transaction/request'
-require 'datatrans/xml/transaction/response'
+require "datatrans/xml/transaction/request"
+require "datatrans/xml/transaction/response"
class Datatrans::XML::Transaction
class VoidRequest < Request
def process
- post(self.datatrans.url(:xml_settlement_url),
- :headers => { 'Content-Type' => 'text/xml' },
- :body => build_void_request.to_s).parsed_response
+ post(datatrans.url(:xml_settlement_url),
+ headers: {"Content-Type" => "text/xml"},
+ body: build_void_request.to_s).parsed_response
end
private
@@ -16,48 +16,62 @@ def build_void_request
xml.amount params[:amount]
xml.currency params[:currency]
xml.uppTransactionId params[:transaction_id]
- xml.reqtype 'DOA'
+ xml.reqtype "DOA"
end
end
end
class VoidResponse < Response
def successful?
- response_code == '01' && response_message == 'cancellation succeeded'
+ response_code == "01" && response_message == "cancellation succeeded"
end
def response_code
- params_root_node['response']['responseCode'] rescue nil
+ params_root_node["response"]["responseCode"]
+ rescue
+ nil
end
def response_message
- params_root_node['response']['responseMessage'] rescue nil
+ params_root_node["response"]["responseMessage"]
+ rescue
+ nil
end
def transaction_id
- params_root_node['request']['uppTransactionId'] rescue nil
+ params_root_node["request"]["uppTransactionId"]
+ rescue
+ nil
end
def reference_number
- params_root_node['refno'] rescue nil
+ params_root_node["refno"]
+ rescue
+ nil
end
def error_code
- params_root_node['error']['errorCode'] rescue nil
+ params_root_node["error"]["errorCode"]
+ rescue
+ nil
end
def error_message
- params_root_node['error']['errorMessage'] rescue nil
+ params_root_node["error"]["errorMessage"]
+ rescue
+ nil
end
def error_detail
- params_root_node['error']['errorDetail'] rescue nil
+ params_root_node["error"]["errorDetail"]
+ rescue
+ nil
end
private
def params_root_node
- params['paymentService']['body']['transaction']
+ params["paymentService"]["body"]["transaction"]
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/common_spec.rb b/spec/common_spec.rb
index d54771e..72d9645 100644
--- a/spec/common_spec.rb
+++ b/spec/common_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe Datatrans::Common do
context "sign" do
before do
- #class Request
+ # class Request
# include Datatrans::Common
- #end
+ # end
@request = Datatrans::XML::Transaction::Request.new(@datatrans, {})
end
it "generates the correct sign" do
amount = 1000
- currency = 'CHF'
- reference_number = 'ABCEDF'
+ currency = "CHF"
+ reference_number = "ABCEDF"
- expect(@request.sign(@datatrans.merchant_id, amount, currency, reference_number)).to eq '4e7d4d5bbde548c586f3b7f109635ffc'
+ expect(@request.sign(@datatrans.merchant_id, amount, currency, reference_number)).to eq "4e7d4d5bbde548c586f3b7f109635ffc"
end
end
end
diff --git a/spec/config_spec.rb b/spec/config_spec.rb
index f07fa55..4f8d57c 100644
--- a/spec/config_spec.rb
+++ b/spec/config_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Datatrans::Config do
describe "Instance Methods" do
before do
- @datatrans = Datatrans::Config.new(:merchant_id => "xxx", :password => "yyy")
+ @datatrans = Datatrans::Config.new(merchant_id: "xxx", password: "yyy")
end
describe "web_transaction" do
diff --git a/spec/json/authorize_spec.rb b/spec/json/authorize_spec.rb
index 69e3e11..37f126d 100644
--- a/spec/json/authorize_spec.rb
+++ b/spec/json/authorize_spec.rb
@@ -24,15 +24,15 @@
}
@expected_request_body = {
- "currency": "CHF",
- "refno": "B4B4B4B4B",
- "amount": 1337,
- "autoSettle": true,
- "paymentMethods": ["ECA", "VIS"],
- "redirect": {
- "successUrl": "https://pay.sandbox.datatrans.com/upp/merchant/successPage.jsp",
- "cancelUrl": "https://pay.sandbox.datatrans.com/upp/merchant/cancelPage.jsp",
- "errorUrl": "https://pay.sandbox.datatrans.com/upp/merchant/errorPage.jsp"
+ currency: "CHF",
+ refno: "B4B4B4B4B",
+ amount: 1337,
+ autoSettle: true,
+ paymentMethods: ["ECA", "VIS"],
+ redirect: {
+ successUrl: "https://pay.sandbox.datatrans.com/upp/merchant/successPage.jsp",
+ cancelUrl: "https://pay.sandbox.datatrans.com/upp/merchant/cancelPage.jsp",
+ errorUrl: "https://pay.sandbox.datatrans.com/upp/merchant/errorPage.jsp"
}
}
@@ -40,7 +40,7 @@
currency: "CHF",
refno: nil,
amount: 1337,
- payment_methods: ["ECA", "VIS"],
+ payment_methods: ["ECA", "VIS"]
}
end
@@ -73,10 +73,10 @@
context "with option specified" do
it "uses option in request_body" do
- params_with_option = @valid_params.merge(option: {"createAlias": true})
+ params_with_option = @valid_params.merge(option: {createAlias: true})
request = Datatrans::JSON::Transaction::Authorize.new(@datatrans, params_with_option)
- expected_request_body_with_option = @expected_request_body.merge("option" => {"createAlias": true})
+ expected_request_body_with_option = @expected_request_body.merge("option" => {createAlias: true})
expect(request.request_body).to eq(expected_request_body_with_option)
end
end
diff --git a/spec/json/merchant_authorize_spec.rb b/spec/json/merchant_authorize_spec.rb
index 19a2a1e..ad04cc9 100644
--- a/spec/json/merchant_authorize_spec.rb
+++ b/spec/json/merchant_authorize_spec.rb
@@ -30,15 +30,15 @@
}
@expected_request_body = {
- "currency": "CHF",
- "refno": "B4B4B4B4B",
- "amount": 1000,
- "card": {
- "alias": "AAABcH0Bq92s3kgAESIAAbGj5NIsAHWC",
- "expiryMonth": "01",
- "expiryYear": "23"
+ currency: "CHF",
+ refno: "B4B4B4B4B",
+ amount: 1000,
+ card: {
+ alias: "AAABcH0Bq92s3kgAESIAAbGj5NIsAHWC",
+ expiryMonth: "01",
+ expiryYear: "23"
},
- "autoSettle": true
+ autoSettle: true
}
@invalid_params = {
diff --git a/spec/json/settle_spec.rb b/spec/json/settle_spec.rb
index dc8b25c..f76e60d 100644
--- a/spec/json/settle_spec.rb
+++ b/spec/json/settle_spec.rb
@@ -13,7 +13,7 @@
}
@valid_params_settle = {
- transaction_id: '230223022302230223',
+ transaction_id: "230223022302230223",
amount: 1337,
currency: "CHF",
refno: "B4B4B4B4B"
diff --git a/spec/json/status_spec.rb b/spec/json/status_spec.rb
index b9ddd2c..2e8ff0b 100644
--- a/spec/json/status_spec.rb
+++ b/spec/json/status_spec.rb
@@ -39,11 +39,11 @@
}
@valid_params = {
- transaction_id: '230223022302230223',
+ transaction_id: "230223022302230223"
}
@invalid_params = {
- transaction_id: '0208020802080208', # wrong number of digits in ID
+ transaction_id: "0208020802080208" # wrong number of digits in ID
}
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index a668fb1..9e9a4ee 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,22 +1,22 @@
-require 'rubygems'
-require 'bundler/setup'
-require 'simplecov'
+require "rubygems"
+require "bundler/setup"
+require "simplecov"
SimpleCov.start
-require 'active_support'
-require 'datatrans'
+require "active_support"
+require "datatrans"
RSpec.configure do |config|
- config.filter_run :focus => true
- config.filter_run_excluding :skip => true
+ config.filter_run focus: true
+ config.filter_run_excluding skip: true
config.run_all_when_everything_filtered = true
config.before(:each) do
@datatrans = Datatrans::Config.new(
- :merchant_id => '1100000000',
- :sign_key => 'd777c17ba2010282c2d2350a68b441ca07a799d294bfaa630b7c8442207c0b69703cc55775b0ca5a4e455b818a9bb10a43669c0c20ce31f4a43f10e0cabb9525',
- :password => 'basic_auth_password',
- :environment => :development
+ merchant_id: "1100000000",
+ sign_key: "d777c17ba2010282c2d2350a68b441ca07a799d294bfaa630b7c8442207c0b69703cc55775b0ca5a4e455b818a9bb10a43669c0c20ce31f4a43f10e0cabb9525",
+ password: "basic_auth_password",
+ environment: :development
)
end
end
diff --git a/spec/web/authorize_spec.rb b/spec/web/authorize_spec.rb
index 90a2b23..6b54c73 100644
--- a/spec/web/authorize_spec.rb
+++ b/spec/web/authorize_spec.rb
@@ -1,73 +1,73 @@
-require 'action_controller'
-require 'spec_helper'
+require "action_controller"
+require "spec_helper"
describe Datatrans::Web::Transaction do
before do
@successful_response = {
- :status => "success",
- :returnCustomerCountry => "CHE",
- :sign => "95f3111123e628eab6469c636e0d3f06",
- :aliasCC => "70323122544311173",
- :maskedCC => "520000xxxxxx0007",
- :responseMessage => "Authorized",
- :useAlias => "yes",
- :expm => "12",
- :responseCode => "01",
- :sign2 => "a9571428be4d9d37b88988656984bfbf",
- :testOnly => "yes",
- :currency => "CHF",
- :amount => "1000",
- :hiddenMode => "yes",
- :expy => "15",
- :merchantId => "1100000000",
- :authorizationCode => "521029462",
- :uppTransactionId => "110808173520119430",
- :refno => "1",
- :uppMsgType => "web",
- :uppCustomerName => "",
- :pmethod => "ECA",
- :reqtype => "NOA",
- :uppCustomerEmail => "customer@email.com",
- :acqAuthorizationCode => "173520"
+ status: "success",
+ returnCustomerCountry: "CHE",
+ sign: "95f3111123e628eab6469c636e0d3f06",
+ aliasCC: "70323122544311173",
+ maskedCC: "520000xxxxxx0007",
+ responseMessage: "Authorized",
+ useAlias: "yes",
+ expm: "12",
+ responseCode: "01",
+ sign2: "a9571428be4d9d37b88988656984bfbf",
+ testOnly: "yes",
+ currency: "CHF",
+ amount: "1000",
+ hiddenMode: "yes",
+ expy: "15",
+ merchantId: "1100000000",
+ authorizationCode: "521029462",
+ uppTransactionId: "110808173520119430",
+ refno: "1",
+ uppMsgType: "web",
+ uppCustomerName: "",
+ pmethod: "ECA",
+ reqtype: "NOA",
+ uppCustomerEmail: "customer@email.com",
+ acqAuthorizationCode: "173520"
}
@successful_swisspost_response = @successful_response.merge({
- :pmethod => "PFC",
- :txtEp2TrxID => "7777777000000001",
- :responseMessage => "YellowPay transaction Ok"
+ pmethod: "PFC",
+ txtEp2TrxID: "7777777000000001",
+ responseMessage: "YellowPay transaction Ok"
})
@failed_response = {
- :status => "error",
- :returnCustomerCountry => "CHE",
- :sign => "95f3123246e628eab6469c636e0d3f06",
- :aliasCC => "70323122544311173",
- :maskedCC => "520000xxxxxx0007",
- :errorMessage => "declined",
- :useAlias => "yes",
- :expm => "12",
- :errorCode => "1403",
- :testOnly => "yes",
- :currency => "CHF",
- :amount => "1000",
- :hiddenMode => "yes",
- :expy => "14",
- :merchantId => "1100000000",
- :errorDetail => "Declined",
- :uppTransactionId => "110808173951050102",
- :refno => "1",
- :uppMsgType => "web",
- :uppCustomerName => "",
- :pmethod => "ECA",
- :reqtype => "NOA",
- :uppCustomerEmail => "customer@email.com"
+ status: "error",
+ returnCustomerCountry: "CHE",
+ sign: "95f3123246e628eab6469c636e0d3f06",
+ aliasCC: "70323122544311173",
+ maskedCC: "520000xxxxxx0007",
+ errorMessage: "declined",
+ useAlias: "yes",
+ expm: "12",
+ errorCode: "1403",
+ testOnly: "yes",
+ currency: "CHF",
+ amount: "1000",
+ hiddenMode: "yes",
+ expy: "14",
+ merchantId: "1100000000",
+ errorDetail: "Declined",
+ uppTransactionId: "110808173951050102",
+ refno: "1",
+ uppMsgType: "web",
+ uppCustomerName: "",
+ pmethod: "ECA",
+ reqtype: "NOA",
+ uppCustomerEmail: "customer@email.com"
}
@valid_params = {
- :refno => 'ABCDEF',
- :amount => 1000,
- :currency => 'CHF',
- :uppCustomerEmail => 'customer@email.com'
+ refno: "ABCDEF",
+ amount: 1000,
+ currency: "CHF",
+ uppCustomerEmail: "customer@email.com"
# also params from view helper needed
}
end
@@ -76,18 +76,18 @@
before do
@transaction = Datatrans::Web::Transaction.new(@datatrans, @valid_params)
- if Gem.loaded_specs['activesupport'].version >= Gem::Version.create('6.0')
- @view = ActionView::Base.new(ActionController::Base.view_paths, {}, {})
+ @view = if Gem.loaded_specs["activesupport"].version >= Gem::Version.create("6.0")
+ ActionView::Base.new(ActionController::Base.view_paths, {}, {})
else
- @view = ActionView::Base.new
+ ActionView::Base.new
end
end
- it 'should generate valid form field string' do
- if Gem.loaded_specs['activesupport'].version >= Gem::Version.create('6.1')
- expected_output = ''
+ it "should generate valid form field string" do
+ expected_output = if Gem.loaded_specs["activesupport"].version >= Gem::Version.create("6.1")
+ ''
else
- expected_output = ''
+ ''
end
expect(@view.datatrans_notification_request_hidden_fields(@datatrans, @transaction)).to eq expected_output
@@ -123,7 +123,7 @@
context "compromised response" do
before do
fake_response = @successful_response
- fake_response[:sign2] = 'invalid'
+ fake_response[:sign2] = "invalid"
allow_any_instance_of(Datatrans::Web::Transaction::AuthorizeResponse).to receive(:params).and_return(fake_response)
@transaction = Datatrans::Web::Transaction.new(@datatrans, @valid_params)
end
diff --git a/spec/xml/authorize_spec.rb b/spec/xml/authorize_spec.rb
index 30337dd..88a0578 100644
--- a/spec/xml/authorize_spec.rb
+++ b/spec/xml/authorize_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Datatrans::XML::Transaction::AuthorizeRequest do
before do
@@ -63,12 +63,12 @@
}
@valid_params = {
- :refno => 'ABCDEF',
- :amount => 1000,
- :currency => 'CHF',
- :aliasCC => '3784982984234',
- :expm => 12,
- :expy => 15
+ refno: "ABCDEF",
+ amount: 1000,
+ currency: "CHF",
+ aliasCC: "3784982984234",
+ expm: 12,
+ expy: 15
}
end
diff --git a/spec/xml/capture_spec.rb b/spec/xml/capture_spec.rb
index 36e552e..6476427 100644
--- a/spec/xml/capture_spec.rb
+++ b/spec/xml/capture_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Datatrans::XML::Transaction::CaptureRequest do
before do
@@ -54,10 +54,10 @@
}
@valid_params = {
- :refno => 'ABCDEF',
- :amount => 1000,
- :currency => 'CHF',
- :transaction_id => '110808142256858007'
+ refno: "ABCDEF",
+ amount: 1000,
+ currency: "CHF",
+ transaction_id: "110808142256858007"
}
end
diff --git a/spec/xml/request_spec.rb b/spec/xml/request_spec.rb
index cafacb5..7c69ae9 100644
--- a/spec/xml/request_spec.rb
+++ b/spec/xml/request_spec.rb
@@ -1,42 +1,41 @@
-require 'spec_helper'
+require "spec_helper"
describe Datatrans::XML::Transaction::Request do
describe "Proxy" do
describe "configured" do
before(:each) do
@datatrans = Datatrans::Config.new(
- :merchant_id => '1100000000',
- :sign_key => 'd777c17ba2010282c2d2350a68b441ca07a799d294bfaa630b7c8442207c0b69703cc55775b0ca5a4e455b818a9bb10a43669c0c20ce31f4a43f10e0cabb9525',
- :password => 'basic_auth_password',
- :key => "value",
- :proxy => {
- :http_proxyaddr => "proxy.com",
- :http_proxyport => 80,
- :http_proxyuser => "hans",
- :http_proxpass => "xxx",
+ merchant_id: "1100000000",
+ sign_key: "d777c17ba2010282c2d2350a68b441ca07a799d294bfaa630b7c8442207c0b69703cc55775b0ca5a4e455b818a9bb10a43669c0c20ce31f4a43f10e0cabb9525",
+ password: "basic_auth_password",
+ key: "value",
+ proxy: {
+ http_proxyaddr: "proxy.com",
+ http_proxyport: 80,
+ http_proxyuser: "hans",
+ http_proxpass: "xxx"
},
- :environment => :development
+ environment: :development
)
-
end
it "forward those options to HTTParty" do
request = Datatrans::XML::Transaction::Request.new(@datatrans, {})
- expect(HTTParty).to receive(:post).with('lirum',
- :basic_auth => {:password => 'basic_auth_password', :username => '1100000000'},
- :params => {:foo => :bar},
- :http_proxpass => 'xxx',
- :http_proxyuser => 'hans',
- :http_proxyaddr => 'proxy.com',
- :http_proxyport => 80)
- request.post('lirum', :params => {:foo => :bar})
+ expect(HTTParty).to receive(:post).with("lirum",
+ basic_auth: {password: "basic_auth_password", username: "1100000000"},
+ params: {foo: :bar},
+ http_proxpass: "xxx",
+ http_proxyuser: "hans",
+ http_proxyaddr: "proxy.com",
+ http_proxyport: 80)
+ request.post("lirum", params: {foo: :bar})
end
end
describe "not configured" do
it "should not add any proxy settings" do
request = Datatrans::XML::Transaction::Request.new(@datatrans, {})
- expect(HTTParty).to receive(:post).with('lirum', :basic_auth => {:password => 'basic_auth_password', :username => '1100000000'}, :params => {:foo => :bar})
- request.post('lirum', :params => {:foo => :bar})
+ expect(HTTParty).to receive(:post).with("lirum", basic_auth: {password: "basic_auth_password", username: "1100000000"}, params: {foo: :bar})
+ request.post("lirum", params: {foo: :bar})
end
end
end
diff --git a/spec/xml/status_spec.rb b/spec/xml/status_spec.rb
index 5ff6517..e9651eb 100644
--- a/spec/xml/status_spec.rb
+++ b/spec/xml/status_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Datatrans::XML::Transaction::StatusRequest do
before do
@@ -17,7 +17,7 @@
"amount" => "500",
"currency" => "CHF",
"authorizationCode" => "891104057",
- "pmethod" => "ECA",
+ "pmethod" => "ECA"
},
"trxStatus" => "response"
},
@@ -43,7 +43,7 @@
"amount" => "",
"currency" => "",
"authorizationCode" => "",
- "pmethod" => "",
+ "pmethod" => ""
},
"trxStatus" => "response"
},
@@ -55,7 +55,7 @@
}
@valid_params = {
- :transaction_id => '111013090000394044',
+ transaction_id: "111013090000394044"
}
end
diff --git a/spec/xml/void_spec.rb b/spec/xml/void_spec.rb
index 492ac86..016e72b 100644
--- a/spec/xml/void_spec.rb
+++ b/spec/xml/void_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Datatrans::XML::Transaction::VoidRequest do
before do
@@ -54,10 +54,10 @@
}
@valid_params = {
- :refno => 'ABCDEF',
- :amount => 1000,
- :currency => 'CHF',
- :transaction_id => '110808143302868124'
+ refno: "ABCDEF",
+ amount: 1000,
+ currency: "CHF",
+ transaction_id: "110808143302868124"
}
end