datatrans 5.1.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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +30 -3
- data/.github/workflows/release.yml +1 -1
- data/.gitignore +1 -1
- data/.ruby-version +1 -1
- data/Appraisals +16 -8
- data/CHANGELOG.md +13 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +151 -0
- data/README.markdown +70 -7
- data/Rakefile +2 -2
- data/datatrans.gemspec +20 -22
- data/gemfiles/rails_5_2.gemfile +2 -2
- data/gemfiles/rails_6_0.gemfile +2 -2
- data/gemfiles/rails_6_1.gemfile +2 -2
- data/gemfiles/rails_7_0.gemfile +2 -2
- data/gemfiles/rails_7_1.gemfile +12 -0
- data/lib/datatrans/common.rb +5 -5
- data/lib/datatrans/config.rb +26 -11
- data/lib/datatrans/json/transaction/authorize.rb +4 -42
- data/lib/datatrans/json/transaction/init.rb +61 -0
- data/lib/datatrans/json/transaction/merchant_authorize.rb +45 -0
- data/lib/datatrans/json/transaction/response.rb +7 -3
- data/lib/datatrans/json/transaction/settle.rb +41 -0
- data/lib/datatrans/json/transaction/status.rb +15 -9
- data/lib/datatrans/json/transaction.rb +30 -8
- data/lib/datatrans/version.rb +1 -1
- data/lib/datatrans/web/transaction/authorize.rb +46 -17
- data/lib/datatrans/web/transaction.rb +10 -4
- data/lib/datatrans/web/view_helper.rb +3 -1
- data/lib/datatrans/xml/transaction/authorize.rb +39 -19
- data/lib/datatrans/xml/transaction/capture.rb +29 -15
- data/lib/datatrans/xml/transaction/request.rb +10 -9
- data/lib/datatrans/xml/transaction/response.rb +4 -2
- data/lib/datatrans/xml/transaction/status.rb +41 -25
- data/lib/datatrans/xml/transaction/void.rb +30 -16
- data/lib/datatrans/xml/transaction.rb +18 -14
- data/lib/datatrans.rb +9 -9
- data/renovate.json +14 -0
- data/spec/common_spec.rb +6 -6
- data/spec/config_spec.rb +2 -2
- data/spec/json/authorize_spec.rb +35 -14
- data/spec/json/init_spec.rb +100 -0
- data/spec/json/merchant_authorize_spec.rb +97 -0
- data/spec/json/settle_spec.rb +55 -0
- data/spec/json/status_spec.rb +2 -2
- data/spec/spec_helper.rb +11 -11
- data/spec/web/init_spec.rb +157 -0
- data/spec/xml/capture_spec.rb +5 -5
- data/spec/xml/{authorize_spec.rb → init_spec.rb} +7 -7
- data/spec/xml/request_spec.rb +21 -22
- data/spec/xml/status_spec.rb +4 -4
- data/spec/xml/void_spec.rb +5 -5
- metadata +13 -4
- data/spec/web/authorize_spec.rb +0 -157
data/lib/datatrans/config.rb
CHANGED
@@ -6,10 +6,10 @@ module Datatrans
|
|
6
6
|
DEFAULT_SIGN_KEY = false
|
7
7
|
|
8
8
|
SUBDOMAINS = {
|
9
|
-
payment_page:
|
10
|
-
server_to_server_api:
|
9
|
+
payment_page: "pay",
|
10
|
+
server_to_server_api: "api"
|
11
11
|
}
|
12
|
-
DOMAIN =
|
12
|
+
DOMAIN = "datatrans.com"
|
13
13
|
|
14
14
|
attr_reader :environment, :merchant_id, :sign_key, :password, :proxy
|
15
15
|
|
@@ -21,10 +21,10 @@ module Datatrans
|
|
21
21
|
# * :proxy (a hash containing :http_proxyaddr, :http_proxyport, :http_proxyuser, :http_proxypass)
|
22
22
|
def initialize(options = {})
|
23
23
|
@merchant_id = options[:merchant_id]
|
24
|
-
raise ArgumentError.new(":merchant_id is required") unless
|
24
|
+
raise ArgumentError.new(":merchant_id is required") unless merchant_id
|
25
25
|
self.environment = options[:environment] || DEFAULT_ENVIRONMENT
|
26
26
|
@password = options[:password]
|
27
|
-
raise ArgumentError.new(":password is required") unless
|
27
|
+
raise ArgumentError.new(":password is required") unless password
|
28
28
|
@sign_key = options[:sign_key] || DEFAULT_SIGN_KEY
|
29
29
|
@proxy = options[:proxy] || {}
|
30
30
|
end
|
@@ -34,7 +34,7 @@ module Datatrans
|
|
34
34
|
if ENVIRONMENTS.include?(environment)
|
35
35
|
@environment = environment
|
36
36
|
else
|
37
|
-
raise "Unknown environment '#{environment}'. Available: #{ENVIRONMENTS.join(
|
37
|
+
raise "Unknown environment '#{environment}'. Available: #{ENVIRONMENTS.join(", ")}"
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -42,20 +42,31 @@ module Datatrans
|
|
42
42
|
def url(what, options = {})
|
43
43
|
case what
|
44
44
|
when :web_authorize_url
|
45
|
+
warn "DEPRECATION WARNING: Support for the payment page is deprecated and will be removed in the next major version. Please use the JSON API instead."
|
46
|
+
|
45
47
|
subdomain = SUBDOMAINS[:payment_page]
|
46
|
-
path =
|
48
|
+
path = "/upp/jsp/upStart.jsp"
|
47
49
|
when :xml_authorize_url
|
50
|
+
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."
|
51
|
+
|
48
52
|
subdomain = SUBDOMAINS[:server_to_server_api]
|
49
|
-
path =
|
53
|
+
path = "/upp/jsp/XML_authorize.jsp"
|
50
54
|
when :xml_settlement_url
|
55
|
+
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."
|
56
|
+
|
51
57
|
subdomain = SUBDOMAINS[:server_to_server_api]
|
52
|
-
path =
|
58
|
+
path = "/upp/jsp/XML_processor.jsp"
|
53
59
|
when :xml_status_url
|
60
|
+
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."
|
61
|
+
|
54
62
|
subdomain = SUBDOMAINS[:server_to_server_api]
|
55
|
-
path =
|
63
|
+
path = "/upp/jsp/XML_status.jsp"
|
56
64
|
when :init_transaction
|
57
65
|
subdomain = SUBDOMAINS[:server_to_server_api]
|
58
66
|
path = "/v1/transactions"
|
67
|
+
when :authorize_transaction
|
68
|
+
subdomain = SUBDOMAINS[:server_to_server_api]
|
69
|
+
path = "/v1/transactions/authorize"
|
59
70
|
when :start_json_transaction
|
60
71
|
subdomain = SUBDOMAINS[:payment_page]
|
61
72
|
path = "/v1/start/#{options[:transaction_id]}"
|
@@ -63,10 +74,14 @@ module Datatrans
|
|
63
74
|
# https://api.sandbox.datatrans.com/v1/transactions/{transactionId}
|
64
75
|
subdomain = SUBDOMAINS[:server_to_server_api]
|
65
76
|
path = "/v1/transactions/#{options[:transaction_id]}"
|
77
|
+
when :json_settle_url
|
78
|
+
# https://api.sandbox.datatrans.com/v1/transactions/{transactionId}/settle
|
79
|
+
subdomain = SUBDOMAINS[:server_to_server_api]
|
80
|
+
path = "/v1/transactions/#{options[:transaction_id]}/settle"
|
66
81
|
else
|
67
82
|
raise "Unknown wanted action '#{what}'."
|
68
83
|
end
|
69
|
-
subdomain +=
|
84
|
+
subdomain += ".sandbox" unless environment == :production
|
70
85
|
"https://#{subdomain}.#{DOMAIN}#{path}"
|
71
86
|
end
|
72
87
|
|
@@ -1,48 +1,10 @@
|
|
1
|
-
|
2
|
-
require 'datatrans/json/transaction/response'
|
1
|
+
require_relative "init"
|
3
2
|
|
4
3
|
class Datatrans::JSON::Transaction
|
5
|
-
class Authorize
|
6
|
-
# class to initialize a new transaction https://api-reference.datatrans.ch/#tag/v1transactions/operation/init
|
7
|
-
attr_accessor :params, :datatrans
|
8
|
-
|
4
|
+
class Authorize < Init
|
9
5
|
def initialize(datatrans, params)
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
def post(url, options = {})
|
15
|
-
options = options
|
16
|
-
.merge(self.datatrans.proxy)
|
17
|
-
.merge(:basic_auth => { :username => self.datatrans.merchant_id, :password => self.datatrans.password })
|
18
|
-
HTTParty.post(url, **options)
|
19
|
-
end
|
20
|
-
|
21
|
-
def process
|
22
|
-
post(self.datatrans.url(:init_transaction),
|
23
|
-
:headers => { 'Content-Type' => 'application/json' },
|
24
|
-
:body => request_body.to_json).parsed_response
|
25
|
-
end
|
26
|
-
|
27
|
-
def request_body
|
28
|
-
{
|
29
|
-
"currency": params[:currency],
|
30
|
-
"refno": params[:refno],
|
31
|
-
"amount": params[:amount],
|
32
|
-
"autoSettle": true,
|
33
|
-
"paymentMethods": params[:payment_methods],
|
34
|
-
"redirect": {
|
35
|
-
"successUrl": params[:success_url],
|
36
|
-
"cancelUrl": params[:cancel_url],
|
37
|
-
"errorUrl": params[:error_url]
|
38
|
-
}
|
39
|
-
}
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class AuthorizeResponse < Response
|
44
|
-
def successful?
|
45
|
-
params["error"].blank? && params["transactionId"].present?
|
6
|
+
warn "[DEPRECATION] `Datatrans::JSON::Transaction::Authorize` is deprecated. Please use `Datatrans::JSON::Transaction::Init` instead."
|
7
|
+
super(datatrans, params)
|
46
8
|
end
|
47
9
|
end
|
48
10
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require "datatrans/json/transaction/response"
|
3
|
+
|
4
|
+
class Datatrans::JSON::Transaction
|
5
|
+
class Init
|
6
|
+
# class to initialize a new transaction https://api-reference.datatrans.ch/#tag/v1transactions/operation/init
|
7
|
+
attr_accessor :params, :datatrans
|
8
|
+
|
9
|
+
def initialize(datatrans, params)
|
10
|
+
@datatrans = datatrans
|
11
|
+
@params = params
|
12
|
+
end
|
13
|
+
|
14
|
+
def post(url, options = {})
|
15
|
+
options = options
|
16
|
+
.merge(datatrans.proxy)
|
17
|
+
.merge(basic_auth: {username: datatrans.merchant_id, password: datatrans.password})
|
18
|
+
HTTParty.post(url, **options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def process
|
22
|
+
post(datatrans.url(:init_transaction),
|
23
|
+
headers: {"Content-Type" => "application/json"},
|
24
|
+
body: request_body.to_json).parsed_response
|
25
|
+
end
|
26
|
+
|
27
|
+
def request_body
|
28
|
+
auto_settle = params[:auto_settle].nil? ? true : params[:auto_settle]
|
29
|
+
|
30
|
+
body = {
|
31
|
+
currency: params[:currency],
|
32
|
+
refno: params[:refno],
|
33
|
+
amount: params[:amount],
|
34
|
+
autoSettle: auto_settle,
|
35
|
+
paymentMethods: params[:payment_methods],
|
36
|
+
redirect: {
|
37
|
+
successUrl: params[:success_url],
|
38
|
+
cancelUrl: params[:cancel_url],
|
39
|
+
errorUrl: params[:error_url]
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
body["option"] = params[:option] if params[:option].present?
|
44
|
+
|
45
|
+
body
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class InitResponse < Response
|
50
|
+
def successful?
|
51
|
+
params["error"].blank? && params["transactionId"].present?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class AuthorizeResponse < InitResponse
|
56
|
+
def initialize(datatrans, params)
|
57
|
+
warn "[DEPRECATION] `Datatrans::JSON::Transaction::AuthorizeResponse` is deprecated. Please use `Datatrans::JSON::Transaction::InitResponse` instead."
|
58
|
+
super(datatrans, params)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require "datatrans/json/transaction/response"
|
3
|
+
|
4
|
+
class Datatrans::JSON::Transaction
|
5
|
+
class MerchantAuthorize
|
6
|
+
# class to authorize a transaction without user interaction https://api-reference.datatrans.ch/#tag/v1transactions/operation/authorize
|
7
|
+
attr_accessor :params, :datatrans
|
8
|
+
|
9
|
+
def initialize(datatrans, params)
|
10
|
+
@datatrans = datatrans
|
11
|
+
@params = params
|
12
|
+
end
|
13
|
+
|
14
|
+
def post(url, options = {})
|
15
|
+
options = options
|
16
|
+
.merge(datatrans.proxy)
|
17
|
+
.merge(basic_auth: {username: datatrans.merchant_id, password: datatrans.password})
|
18
|
+
HTTParty.post(url, **options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def process
|
22
|
+
post(datatrans.url(:authorize_transaction),
|
23
|
+
headers: {"Content-Type" => "application/json"},
|
24
|
+
body: request_body.to_json).parsed_response
|
25
|
+
end
|
26
|
+
|
27
|
+
def request_body
|
28
|
+
auto_settle = params[:auto_settle].nil? ? true : params[:auto_settle]
|
29
|
+
|
30
|
+
{
|
31
|
+
currency: params[:currency],
|
32
|
+
refno: params[:refno],
|
33
|
+
amount: params[:amount],
|
34
|
+
card: params[:card],
|
35
|
+
autoSettle: auto_settle
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class MerchantAuthorizeResponse < Response
|
41
|
+
def successful?
|
42
|
+
params["error"].blank? && params["transactionId"].present?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -8,15 +8,19 @@ class Datatrans::JSON::Transaction
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def successful?
|
11
|
-
raise
|
11
|
+
raise "overwrite in subclass!"
|
12
12
|
end
|
13
13
|
|
14
14
|
def error_code
|
15
|
-
params["error"]["code"]
|
15
|
+
params["error"]["code"]
|
16
|
+
rescue
|
17
|
+
nil
|
16
18
|
end
|
17
19
|
|
18
20
|
def error_message
|
19
|
-
params["error"]["message"]
|
21
|
+
params["error"]["message"]
|
22
|
+
rescue
|
23
|
+
nil
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require "datatrans/json/transaction/response"
|
3
|
+
|
4
|
+
class Datatrans::JSON::Transaction
|
5
|
+
class Settle
|
6
|
+
# Class to settle a transaction https://api-reference.datatrans.ch/#tag/v1transactions/operation/settle
|
7
|
+
attr_accessor :params, :datatrans
|
8
|
+
|
9
|
+
def initialize(datatrans, params)
|
10
|
+
@datatrans = datatrans
|
11
|
+
@params = params
|
12
|
+
end
|
13
|
+
|
14
|
+
def post(url, options = {})
|
15
|
+
options = options
|
16
|
+
.merge(datatrans.proxy)
|
17
|
+
.merge(basic_auth: {username: datatrans.merchant_id, password: datatrans.password})
|
18
|
+
HTTParty.post(url, **options)
|
19
|
+
end
|
20
|
+
|
21
|
+
def process
|
22
|
+
post(datatrans.url(:json_settle_url, transaction_id: params[:transaction_id]),
|
23
|
+
headers: {"Content-Type" => "application/json"},
|
24
|
+
body: request_body.to_json).parsed_response
|
25
|
+
end
|
26
|
+
|
27
|
+
def request_body
|
28
|
+
{
|
29
|
+
currency: params[:currency],
|
30
|
+
amount: params[:amount],
|
31
|
+
refno: params[:refno]
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class SettleResponse < Response
|
37
|
+
def successful?
|
38
|
+
params["error"].blank?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "httparty"
|
2
|
+
require "datatrans/json/transaction/response"
|
3
3
|
|
4
4
|
class Datatrans::JSON::Transaction
|
5
5
|
class Status
|
@@ -13,14 +13,14 @@ class Datatrans::JSON::Transaction
|
|
13
13
|
|
14
14
|
def get(url, options = {})
|
15
15
|
options = options
|
16
|
-
.merge(
|
17
|
-
.merge(:
|
16
|
+
.merge(datatrans.proxy)
|
17
|
+
.merge(basic_auth: {username: datatrans.merchant_id, password: datatrans.password})
|
18
18
|
HTTParty.get(url, **options)
|
19
19
|
end
|
20
20
|
|
21
21
|
def process
|
22
|
-
get(
|
23
|
-
:
|
22
|
+
get(datatrans.url(:json_status_url, transaction_id: params[:transaction_id]),
|
23
|
+
headers: {"Content-Type" => "application/json"}).parsed_response
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -30,15 +30,21 @@ class Datatrans::JSON::Transaction
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def response_code
|
33
|
-
params["status"]
|
33
|
+
params["status"]
|
34
|
+
rescue
|
35
|
+
nil
|
34
36
|
end
|
35
37
|
|
36
38
|
def reference_number
|
37
|
-
params["refno"]
|
39
|
+
params["refno"]
|
40
|
+
rescue
|
41
|
+
nil
|
38
42
|
end
|
39
43
|
|
40
44
|
def amount
|
41
|
-
params["detail"]["settle"]["amount"]
|
45
|
+
params["detail"]["settle"]["amount"]
|
46
|
+
rescue
|
47
|
+
nil
|
42
48
|
end
|
43
49
|
end
|
44
50
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "active_support/core_ext/hash"
|
2
2
|
|
3
3
|
module Datatrans::JSON
|
4
4
|
class Transaction
|
@@ -11,22 +11,44 @@ module Datatrans::JSON
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def authorize
|
14
|
-
|
15
|
-
|
14
|
+
warn "[DEPRECATION] `Datatrans::JSON::Transaction#authorize` is deprecated. Please use `Datatrans::JSON::Transaction#init` instead."
|
15
|
+
|
16
|
+
self.request = Authorize.new(datatrans, params)
|
17
|
+
@response = AuthorizeResponse.new(datatrans, request.process)
|
18
|
+
@response.successful?
|
19
|
+
end
|
20
|
+
|
21
|
+
def init
|
22
|
+
self.request = Init.new(datatrans, params)
|
23
|
+
@response = InitResponse.new(datatrans, request.process)
|
24
|
+
@response.successful?
|
25
|
+
end
|
26
|
+
|
27
|
+
def merchant_authorize
|
28
|
+
self.request = MerchantAuthorize.new(datatrans, params)
|
29
|
+
@response = MerchantAuthorizeResponse.new(datatrans, request.process)
|
16
30
|
@response.successful?
|
17
31
|
end
|
18
32
|
|
19
33
|
def status
|
20
|
-
self.request = Status.new(
|
21
|
-
@response = StatusResponse.new(
|
34
|
+
self.request = Status.new(datatrans, params)
|
35
|
+
@response = StatusResponse.new(datatrans, request.process)
|
36
|
+
@response.successful?
|
37
|
+
end
|
38
|
+
|
39
|
+
def settle
|
40
|
+
self.request = Settle.new(datatrans, params)
|
41
|
+
@response = SettleResponse.new(datatrans, request.process)
|
22
42
|
@response.successful?
|
23
43
|
end
|
24
44
|
|
25
45
|
def transaction_path
|
26
|
-
|
46
|
+
datatrans.url(:start_json_transaction, transaction_id: params[:transaction_id])
|
27
47
|
end
|
28
48
|
end
|
29
49
|
end
|
30
50
|
|
31
|
-
require
|
32
|
-
require
|
51
|
+
require "datatrans/json/transaction/authorize"
|
52
|
+
require "datatrans/json/transaction/merchant_authorize"
|
53
|
+
require "datatrans/json/transaction/status"
|
54
|
+
require "datatrans/json/transaction/settle"
|
data/lib/datatrans/version.rb
CHANGED
@@ -3,78 +3,107 @@ class Datatrans::Web::Transaction
|
|
3
3
|
attr_accessor :params, :datatrans
|
4
4
|
|
5
5
|
def initialize(datatrans, params)
|
6
|
+
warn "DEPRECATION WARNING: Support for the payment page 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
13
|
raise Datatrans::InvalidSignatureError unless valid_signature?
|
12
|
-
response_code ==
|
14
|
+
response_code == "01" && status == "success" && !errors_occurred?
|
13
15
|
end
|
14
16
|
|
15
17
|
def valid_signature?
|
16
18
|
# TODO: does not make sense... true if errors?
|
17
19
|
return true if errors_occurred? # no sign2 sent on error
|
18
|
-
sign(
|
20
|
+
sign(datatrans.merchant_id, params[:amount], params[:currency], params[:uppTransactionId]) == params[:sign2]
|
19
21
|
end
|
20
22
|
|
21
23
|
def status
|
22
|
-
params[:status]
|
24
|
+
params[:status]
|
25
|
+
rescue
|
26
|
+
nil
|
23
27
|
end
|
24
28
|
|
25
29
|
def response_code
|
26
|
-
params[:responseCode]
|
30
|
+
params[:responseCode]
|
31
|
+
rescue
|
32
|
+
nil
|
27
33
|
end
|
28
34
|
|
29
35
|
def response_message
|
30
|
-
params[:responseMessage]
|
36
|
+
params[:responseMessage]
|
37
|
+
rescue
|
38
|
+
nil
|
31
39
|
end
|
32
40
|
|
33
41
|
def transaction_id
|
34
|
-
params[:uppTransactionId]
|
42
|
+
params[:uppTransactionId]
|
43
|
+
rescue
|
44
|
+
nil
|
35
45
|
end
|
36
46
|
|
37
47
|
def reference_number
|
38
|
-
params[:refno]
|
48
|
+
params[:refno]
|
49
|
+
rescue
|
50
|
+
nil
|
39
51
|
end
|
40
52
|
|
41
53
|
def authorization_code
|
42
|
-
params[:authorizationCode]
|
54
|
+
params[:authorizationCode]
|
55
|
+
rescue
|
56
|
+
nil
|
43
57
|
end
|
44
58
|
|
45
59
|
def payment_method
|
46
|
-
params[:pmethod]
|
60
|
+
params[:pmethod]
|
61
|
+
rescue
|
62
|
+
nil
|
47
63
|
end
|
48
64
|
|
49
65
|
def masked_cc
|
50
|
-
params[:maskedCC]
|
66
|
+
params[:maskedCC]
|
67
|
+
rescue
|
68
|
+
nil
|
51
69
|
end
|
52
70
|
|
53
71
|
def exp_year
|
54
|
-
params[:expy]
|
72
|
+
params[:expy]
|
73
|
+
rescue
|
74
|
+
nil
|
55
75
|
end
|
56
76
|
|
57
77
|
def exp_month
|
58
|
-
params[:expm]
|
78
|
+
params[:expm]
|
79
|
+
rescue
|
80
|
+
nil
|
59
81
|
end
|
60
82
|
|
61
83
|
def creditcard_alias
|
62
|
-
params[:aliasCC]
|
84
|
+
params[:aliasCC]
|
85
|
+
rescue
|
86
|
+
nil
|
63
87
|
end
|
64
88
|
|
65
89
|
def error_code
|
66
|
-
params[:errorCode]
|
90
|
+
params[:errorCode]
|
91
|
+
rescue
|
92
|
+
nil
|
67
93
|
end
|
68
94
|
|
69
95
|
def error_message
|
70
|
-
params[:errorMessage]
|
96
|
+
params[:errorMessage]
|
97
|
+
rescue
|
98
|
+
nil
|
71
99
|
end
|
72
100
|
|
73
101
|
def error_detail
|
74
|
-
params[:errorDetail]
|
102
|
+
params[:errorDetail]
|
103
|
+
rescue
|
104
|
+
nil
|
75
105
|
end
|
76
106
|
|
77
|
-
|
78
107
|
private
|
79
108
|
|
80
109
|
def errors_occurred?
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "active_support/core_ext/hash"
|
2
2
|
|
3
3
|
module Datatrans::Web
|
4
4
|
class Transaction
|
@@ -8,15 +8,17 @@ module Datatrans::Web
|
|
8
8
|
attr_reader :response, :params, :datatrans
|
9
9
|
|
10
10
|
def initialize(datatrans, params)
|
11
|
+
warn "DEPRECATION WARNING: Support for the payment page is deprecated and will be removed in the next major version. Please use the JSON API instead."
|
12
|
+
|
11
13
|
@datatrans = datatrans
|
12
14
|
params = params.to_hash
|
13
15
|
params.symbolize_keys!
|
14
|
-
params.reverse_merge!(:
|
16
|
+
params.reverse_merge!(reqtype: "NOA", useAlias: "yes", hiddenMode: "yes")
|
15
17
|
@params = params
|
16
18
|
end
|
17
19
|
|
18
20
|
def signature
|
19
|
-
sign(
|
21
|
+
sign(datatrans.merchant_id, params[:amount], params[:currency], params[:refno])
|
20
22
|
end
|
21
23
|
|
22
24
|
def authorize
|
@@ -24,6 +26,10 @@ module Datatrans::Web
|
|
24
26
|
@response.successful?
|
25
27
|
end
|
26
28
|
|
29
|
+
def respond_to_missing?(method, *)
|
30
|
+
response.respond_to?(method.to_sym) || super
|
31
|
+
end
|
32
|
+
|
27
33
|
def method_missing(method, *args, &block)
|
28
34
|
if response.respond_to? method.to_sym
|
29
35
|
response.send(method)
|
@@ -34,4 +40,4 @@ module Datatrans::Web
|
|
34
40
|
end
|
35
41
|
end
|
36
42
|
|
37
|
-
require
|
43
|
+
require "datatrans/web/transaction/authorize"
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Datatrans::Web
|
2
2
|
module ViewHelper
|
3
3
|
def datatrans_notification_request_hidden_fields(datatrans, transaction)
|
4
|
+
warn "DEPRECATION WARNING: Support for the payment page is deprecated and will be removed in the next major version. Please use the JSON API instead."
|
5
|
+
|
4
6
|
fields = [
|
5
7
|
hidden_field_tag(:merchantId, datatrans.merchant_id),
|
6
8
|
hidden_field_tag(:hiddenMode, transaction.params[:hiddenMode]),
|
@@ -10,7 +12,7 @@ module Datatrans::Web
|
|
10
12
|
hidden_field_tag(:useAlias, transaction.params[:useAlias]),
|
11
13
|
hidden_field_tag(:sign, transaction.signature),
|
12
14
|
hidden_field_tag(:refno, transaction.params[:refno]),
|
13
|
-
hidden_field_tag(:uppCustomerDetails, transaction.params[:uppCustomerDetails])
|
15
|
+
hidden_field_tag(:uppCustomerDetails, transaction.params[:uppCustomerDetails])
|
14
16
|
]
|
15
17
|
|
16
18
|
[:uppCustomerName, :uppCustomerEmail].each do |field_name|
|