cybersource_rest_client 0.0.10 → 0.0.11
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/lib/AuthenticationSDK/authentication/http/GetSignatureParameter.rb +64 -0
- data/lib/AuthenticationSDK/authentication/http/HttpSignatureHeader.rb +52 -0
- data/lib/AuthenticationSDK/authentication/jwt/JwtToken.rb +62 -0
- data/lib/AuthenticationSDK/authentication/payloadDigest/digest.rb +10 -0
- data/lib/AuthenticationSDK/core/Authorization.rb +24 -0
- data/lib/AuthenticationSDK/core/ITokenGeneration.rb +4 -0
- data/lib/AuthenticationSDK/core/Logger.rb +26 -0
- data/lib/AuthenticationSDK/core/MerchantConfig.rb +181 -0
- data/{AuthenticationSDK → lib/AuthenticationSDK}/resource/TRRReports.json +0 -0
- data/{AuthenticationSDK → lib/AuthenticationSDK}/resource/cybs.yml +0 -0
- data/{AuthenticationSDK → lib/AuthenticationSDK}/resource/request.json +0 -0
- data/{AuthenticationSDK → lib/AuthenticationSDK}/resource/request_capture.json +0 -0
- data/{AuthenticationSDK → lib/AuthenticationSDK}/resource/testrest.p12 +0 -0
- data/{AuthenticationSDK → lib/AuthenticationSDK}/spec/Authorization_spec.rb +0 -0
- data/{AuthenticationSDK → lib/AuthenticationSDK}/spec/MerchantConfigData.rb +0 -0
- data/{AuthenticationSDK → lib/AuthenticationSDK}/spec/MerchantConfig_spec.rb +0 -0
- data/{AuthenticationSDK → lib/AuthenticationSDK}/spec/PostRequestData.json +0 -0
- data/{AuthenticationSDK → lib/AuthenticationSDK}/spec/PutRequestData.json +0 -0
- data/{AuthenticationSDK → lib/AuthenticationSDK}/spec/ResponseCodeMessage_spec.rb +0 -0
- data/{AuthenticationSDK → lib/AuthenticationSDK}/spec/spec_helper.rb +0 -0
- data/lib/AuthenticationSDK/util/ApiException.rb +19 -0
- data/lib/AuthenticationSDK/util/Cache.rb +36 -0
- data/lib/AuthenticationSDK/util/Constants.rb +138 -0
- data/lib/AuthenticationSDK/util/PropertiesUtil.rb +19 -0
- data/lib/AuthenticationSDK/util/Utility.rb +32 -0
- data/lib/cybersource_rest_client/api_client.rb +11 -11
- data/lib/cybersource_rest_client.rb +13 -0
- metadata +27 -29
- data/AuthenticationSDK/AuthenticationSDK-0.0.1.gem +0 -0
- data/AuthenticationSDK/Cybersource.gemspec +0 -25
- data/AuthenticationSDK/authentication/http/GetSignatureParameter.rb +0 -64
- data/AuthenticationSDK/authentication/http/HttpSignatureHeader.rb +0 -52
- data/AuthenticationSDK/authentication/jwt/JwtToken.rb +0 -62
- data/AuthenticationSDK/authentication/payloadDigest/digest.rb +0 -10
- data/AuthenticationSDK/core/Authorization.rb +0 -24
- data/AuthenticationSDK/core/ITokenGeneration.rb +0 -4
- data/AuthenticationSDK/core/Logger.rb +0 -26
- data/AuthenticationSDK/core/MerchantConfig.rb +0 -181
- data/AuthenticationSDK/util/ApiException.rb +0 -19
- data/AuthenticationSDK/util/Cache.rb +0 -36
- data/AuthenticationSDK/util/Constants.rb +0 -138
- data/AuthenticationSDK/util/PropertiesUtil.rb +0 -20
- data/AuthenticationSDK/util/Utility.rb +0 -31
@@ -1,181 +0,0 @@
|
|
1
|
-
require_relative './Logger.rb'
|
2
|
-
require_relative '../util/Constants.rb'
|
3
|
-
require_relative '../util/ApiException.rb'
|
4
|
-
public
|
5
|
-
# This fuction has all the merchantConfig properties getters and setters methods
|
6
|
-
class Merchantconfig
|
7
|
-
def initialize(cybsPropertyObj)
|
8
|
-
# Common Parameters
|
9
|
-
@merchantId = cybsPropertyObj['merchantID']
|
10
|
-
@runEnvironment = cybsPropertyObj['runEnvironment']
|
11
|
-
@authenticationType = cybsPropertyObj['authenticationType']
|
12
|
-
@logDirectory = cybsPropertyObj['logDirectory']
|
13
|
-
@logSize = cybsPropertyObj['logSize']
|
14
|
-
@enableLog = cybsPropertyObj['enableLog']
|
15
|
-
@proxyAddress = cybsPropertyObj['proxyAddress']
|
16
|
-
@proxyPort = cybsPropertyObj['proxyPort']
|
17
|
-
@getId = ''
|
18
|
-
@requestHost = ''
|
19
|
-
@requestTarget = ''
|
20
|
-
@requestJsonData = ''
|
21
|
-
# HTTP Parameters
|
22
|
-
@merchantSecretKey = cybsPropertyObj['merchantsecretKey']
|
23
|
-
@merchantKeyId = cybsPropertyObj['merchantKeyId']
|
24
|
-
# JWT Parameters
|
25
|
-
@keysDirectory = cybsPropertyObj['keysDirectory']
|
26
|
-
@keyAlias = cybsPropertyObj['keyAlias']
|
27
|
-
@keyPass = cybsPropertyObj['keyPass']
|
28
|
-
@keyFilename = cybsPropertyObj['keyFilename']
|
29
|
-
@logFilename = cybsPropertyObj['logFilename']
|
30
|
-
validateMerchantDetails()
|
31
|
-
logAllProperties(cybsPropertyObj)
|
32
|
-
end
|
33
|
-
#fall back logic
|
34
|
-
def validateMerchantDetails()
|
35
|
-
logmessage=''
|
36
|
-
if @enableLog.to_s.empty?
|
37
|
-
@enableLog = true
|
38
|
-
elsif @enableLog.instance_of? Fixnum
|
39
|
-
@enableLog = @enableLog.to_s
|
40
|
-
end
|
41
|
-
if @logSize.to_s.empty?
|
42
|
-
@logSize = Constants::DEFAULT_LOG_SIZE
|
43
|
-
elsif !@logSize.instance_of? Fixnum
|
44
|
-
@logSize=@logSize.to_i
|
45
|
-
end
|
46
|
-
if @logDirectory.to_s.empty? || !Dir.exist?(@logDirectory)
|
47
|
-
@logDirectory = Constants::DEFAULT_LOG_DIRECTORY
|
48
|
-
unless Dir.exist?(@logDirectory)
|
49
|
-
Dir.mkdir(Constants::DEFAULT_LOG_DIRECTORY)
|
50
|
-
end
|
51
|
-
logmessage = Constants::WARNING_PREFIX + Constants::INVALID_LOG_DIRECTORY + File.expand_path(@logDirectory)
|
52
|
-
end
|
53
|
-
if @logFilename.to_s.empty?
|
54
|
-
@logFilename = Constants::DEFAULT_LOGFILE_NAME
|
55
|
-
elsif !@logFilename.instance_of? String
|
56
|
-
@logFilename=@logFilename.to_s
|
57
|
-
end
|
58
|
-
@log_obj = Log.new @logDirectory,@logFilename,@logSize,@enableLog
|
59
|
-
@log_obj.logger.info('START> =======================================')
|
60
|
-
if !logmessage.to_s.empty?
|
61
|
-
ApiException.new.apiwarning(logmessage,log_obj)
|
62
|
-
end
|
63
|
-
if @merchantId.to_s.empty?
|
64
|
-
err = raise StandardError.new(Constants::ERROR_PREFIX + Constants::MERCHANT_ID_NULL)
|
65
|
-
ApiException.new.apiexception(err,log_obj)
|
66
|
-
elsif !@merchantId.instance_of? String
|
67
|
-
@merchantId=@merchantId.to_s
|
68
|
-
end
|
69
|
-
if @authenticationType.to_s.empty?
|
70
|
-
err = raise StandardError.new(Constants::ERROR_PREFIX + Constants::AUTH_TYPE_MANDATORY)
|
71
|
-
ApiException.new.apiexception(err,log_obj)
|
72
|
-
end
|
73
|
-
if !@authenticationType.instance_of? String
|
74
|
-
err = raise StandardError.new(Constants::ERROR_PREFIX+ Constants::AUTH_ERROR)
|
75
|
-
ApiException.new.apiexception(err,log_obj)
|
76
|
-
end
|
77
|
-
if !@runEnvironment.to_s.empty?
|
78
|
-
if !@runEnvironment.instance_of? String
|
79
|
-
@requestHost = @runEnvironment.to_s
|
80
|
-
elsif @runEnvironment.upcase == Constants::RUN_ENV_PROD
|
81
|
-
@requestHost = Constants::PRODUCTION_URL
|
82
|
-
elsif @runEnvironment.upcase == Constants::RUN_ENV_SANDBOX
|
83
|
-
@requestHost = Constants::SANDBOX_URL
|
84
|
-
else
|
85
|
-
@requestHost = @runEnvironment
|
86
|
-
end
|
87
|
-
elsif @runEnvironment.to_s.empty?
|
88
|
-
err = raise StandardError.new(Constants::ERROR_PREFIX + Constants::RUN_ENVIRONMENT)
|
89
|
-
ApiException.new.apiexception(err,log_obj)
|
90
|
-
end
|
91
|
-
if @authenticationType.upcase == Constants::AUTH_TYPE_JWT
|
92
|
-
if @keyAlias.to_s.empty?
|
93
|
-
@keyAlias = @merchantId
|
94
|
-
ApiException.new.apiwarning(Constants::WARNING_PREFIX + Constants::KEY_ALIAS_NULL_EMPTY, log_obj)
|
95
|
-
elsif !@keyAlias.instance_of? String
|
96
|
-
@keyAlias=@keyAlias.to_s
|
97
|
-
elsif @keyAlias != @merchantId
|
98
|
-
@keyAlias = @merchantId
|
99
|
-
ApiException.new.apiwarning(Constants::WARNING_PREFIX + Constants::INCORRECT_KEY_ALIAS, log_obj)
|
100
|
-
end
|
101
|
-
if @keyPass.to_s.empty?
|
102
|
-
@keyPass = @merchantId
|
103
|
-
ApiException.new.apiwarning(Constants::WARNING_PREFIX + Constants::KEY_PASS_NULL, log_obj)
|
104
|
-
elsif !@keyPass.instance_of? String
|
105
|
-
@keyPass=@keyPass.to_s
|
106
|
-
end
|
107
|
-
if @keysDirectory.to_s.empty?
|
108
|
-
@keysDirectory = Constants::DEFAULT_KEY_DIRECTORY
|
109
|
-
ApiException.new.apiwarning(Constants::WARNING_PREFIX + Constants::KEY_DIRECTORY_EMPTY + @keysDirectory, log_obj)
|
110
|
-
elsif !@keysDirectory.instance_of? String
|
111
|
-
@keysDirectory=@keysDirectory.to_s
|
112
|
-
end
|
113
|
-
if @keyFilename.to_s.empty?
|
114
|
-
@keyFilename = @merchantId
|
115
|
-
ApiException.new.apiwarning(Constants::WARNING_PREFIX + Constants::KEY_FILE_NAME_NULL_EMPTY, log_obj)
|
116
|
-
elsif !@keyFilename.instance_of? String
|
117
|
-
@keyFilename=@keyFilename.to_s
|
118
|
-
end
|
119
|
-
end
|
120
|
-
if @authenticationType.upcase == Constants::AUTH_TYPE_HTTP
|
121
|
-
if @merchantKeyId.to_s.empty?
|
122
|
-
err = raise StandardError.new(Constants::ERROR_PREFIX+ Constants::MERCHANT_KEY_ID_MANDATORY)
|
123
|
-
ApiException.new.apiexception(err,log_obj)
|
124
|
-
elsif !@merchantKeyId.instance_of? String
|
125
|
-
@merchantKeyId=@merchantKeyId.to_s
|
126
|
-
end
|
127
|
-
if @merchantSecretKey.to_s.empty?
|
128
|
-
err = raise StandardError.new(Constants::ERROR_PREFIX+ Constants::MERCHANT_SECRET_KEY_MANDATORY)
|
129
|
-
ApiException.new.apiexception(err,log_obj)
|
130
|
-
elsif !@merchantSecretKey.instance_of? String
|
131
|
-
@merchantSecretKey=@merchantSecretKey.to_s
|
132
|
-
end
|
133
|
-
end
|
134
|
-
if !@proxyAddress.instance_of? String
|
135
|
-
@proxyAddress=@proxyAddress.to_s
|
136
|
-
end
|
137
|
-
if !@proxyPort.instance_of? String
|
138
|
-
@proxyPort=@proxyPort.to_s
|
139
|
-
end
|
140
|
-
end
|
141
|
-
def logAllProperties(propertyObj)
|
142
|
-
merchantConfig = ''
|
143
|
-
hiddenProperties = (Constants::HIDDEN_MERCHANT_PROPERTIES).split(',')
|
144
|
-
hiddenPropArray = Array.new
|
145
|
-
hiddenProperties.each do |value|
|
146
|
-
hiddenPropArray << value.strip
|
147
|
-
end
|
148
|
-
hiddenPropArray.each do |prop|
|
149
|
-
propertyObj.each do |key, value|
|
150
|
-
if key == prop
|
151
|
-
propertyObj.delete(key)
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
@log_obj.logger.info('MERCHCFG >' + propertyObj.to_s)
|
156
|
-
end
|
157
|
-
|
158
|
-
# getter and setter methods
|
159
|
-
attr_accessor :merchantId
|
160
|
-
attr_accessor :merchantSecretKey
|
161
|
-
attr_accessor :merchantKeyId
|
162
|
-
attr_accessor :authenticationType
|
163
|
-
attr_accessor :keysDirectory
|
164
|
-
attr_accessor :requestHost
|
165
|
-
attr_accessor :keyAlias
|
166
|
-
attr_accessor :keyPass
|
167
|
-
attr_accessor :keyFilename
|
168
|
-
attr_accessor :requestJsonData
|
169
|
-
attr_accessor :requestUrl
|
170
|
-
attr_accessor :requestType
|
171
|
-
attr_accessor :getId
|
172
|
-
attr_accessor :logDirectory
|
173
|
-
attr_accessor :logFilename
|
174
|
-
attr_accessor :enableLog
|
175
|
-
attr_accessor :logSize
|
176
|
-
attr_accessor :logger
|
177
|
-
attr_accessor :proxyAddress
|
178
|
-
attr_accessor :proxyPort
|
179
|
-
attr_accessor :requestTarget
|
180
|
-
attr_accessor :log_obj
|
181
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
public
|
2
|
-
class ApiException
|
3
|
-
def apiexception(err,log_Obj)
|
4
|
-
log_Obj.logger.error(err.message)
|
5
|
-
if !err.backtrace.to_s.empty?
|
6
|
-
log_Obj.logger.error(err.backtrace)
|
7
|
-
end
|
8
|
-
log_Obj.logger.info('END> =======================================')
|
9
|
-
puts 'Check log for more details.'
|
10
|
-
end
|
11
|
-
def apiwarning(message,log_Obj)
|
12
|
-
log_Obj.logger.warn(message)
|
13
|
-
end
|
14
|
-
def customerror(message,log_Obj)
|
15
|
-
log_Obj.logger.error(message)
|
16
|
-
log_Obj.logger.info('END> =======================================')
|
17
|
-
puts 'Check log for more details.'
|
18
|
-
end
|
19
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
require 'openssl'
|
2
|
-
require 'base64'
|
3
|
-
public
|
4
|
-
# P12 file certificate Cache
|
5
|
-
class Cache
|
6
|
-
def fetchCachedCertificate(filePath, p12File, keyPass, cacheObj)
|
7
|
-
certCache = cacheObj.read('certiFromP12File')
|
8
|
-
cachedLastModifiedTimeStamp = cacheObj.read('certificateLastModifiedTimeStamp')
|
9
|
-
if File.exist?(filePath)
|
10
|
-
currentFileLastModifiedTime = File.mtime(filePath)
|
11
|
-
if certCache.to_s.empty? || cachedLastModifiedTimeStamp.to_s.empty?
|
12
|
-
certificateFromP12File = getCertificate(p12File, keyPass, cacheObj, currentFileLastModifiedTime)
|
13
|
-
return certificateFromP12File
|
14
|
-
elsif currentFileLastModifiedTime > cachedLastModifiedTimeStamp
|
15
|
-
# Function call to read the file and put values to new cache
|
16
|
-
certificateFromP12File = getCertificate(p12File, keyPass, cacheObj, currentFileLastModifiedTime)
|
17
|
-
return certificateFromP12File
|
18
|
-
else
|
19
|
-
return certCache
|
20
|
-
end
|
21
|
-
else
|
22
|
-
raise Constants::ERROR_PREFIX + Constants::FILE_NOT_FOUND + filePath
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def getCertificate(p12File, keyPass, cacheObj, currentFileLastModifiedTime)
|
27
|
-
p12FilePath = OpenSSL::PKCS12.new(p12File, keyPass)
|
28
|
-
# Generating certificate from p12File.
|
29
|
-
x5CertPem = OpenSSL::X509::Certificate.new(p12FilePath.certificate)
|
30
|
-
# Converting Certificate format from PEM TO DER to remove header and footer of the certificate.
|
31
|
-
x5CertDer = Base64.strict_encode64(x5CertPem.to_der)
|
32
|
-
cacheObj.write('certiFromP12File', x5CertDer)
|
33
|
-
cacheObj.write('certificateLastModifiedTimeStamp', currentFileLastModifiedTime)
|
34
|
-
return x5CertDer
|
35
|
-
end
|
36
|
-
end
|
@@ -1,138 +0,0 @@
|
|
1
|
-
class Constants
|
2
|
-
|
3
|
-
GET_REQUEST_TYPE_LOWER = 'get' unless const_defined?(:GET_REQUEST_TYPE_LOWER)
|
4
|
-
|
5
|
-
POST_REQUEST_TYPE_LOWER = 'post' unless const_defined?(:POST_REQUEST_TYPE_LOWER)
|
6
|
-
|
7
|
-
PUT_REQUEST_TYPE_LOWER = 'put' unless const_defined?(:PUT_REQUEST_TYPE_LOWER)
|
8
|
-
|
9
|
-
PATCH_REQUEST_TYPE_LOWER = 'patch' unless const_defined?(:PATCH_REQUEST_TYPE_LOWER)
|
10
|
-
|
11
|
-
DELETE_REQUEST_TYPE_LOWER = 'delete' unless const_defined?(:DELETE_REQUEST_TYPE_LOWER)
|
12
|
-
|
13
|
-
GET_REQUEST_TYPE = 'GET' unless const_defined?(:GET_REQUEST_TYPE)
|
14
|
-
|
15
|
-
POST_REQUEST_TYPE = 'POST' unless const_defined?(:POST_REQUEST_TYPE)
|
16
|
-
|
17
|
-
PUT_REQUEST_TYPE = 'PUT' unless const_defined?(:PUT_REQUEST_TYPE)
|
18
|
-
|
19
|
-
PATCH_REQUEST_TYPE = 'PATCH' unless const_defined?(:PATCH_REQUEST_TYPE)
|
20
|
-
|
21
|
-
DELETE_REQUEST_TYPE = 'DELETE' unless const_defined?(:DELETE_REQUEST_TYPE)
|
22
|
-
|
23
|
-
V_C_MERCHANT_ID = 'v-c-merchant-id' unless const_defined?(:V_C_MERCHANT_ID)
|
24
|
-
|
25
|
-
HOST = 'host' unless const_defined?(:HOST)
|
26
|
-
|
27
|
-
DATE = 'date' unless const_defined?(:DATE)
|
28
|
-
|
29
|
-
REQUEST_TARGET = '(request-target)' unless const_defined?(:REQUEST_TARGET)
|
30
|
-
|
31
|
-
DIGEST = 'digest' unless const_defined?(:DIGEST)
|
32
|
-
|
33
|
-
SIGNATURE = 'Signature' unless const_defined?(:SIGNATURE)
|
34
|
-
|
35
|
-
HTTPS_URI_PREFIX = 'https://' unless const_defined?(:HTTPS_URI_PREFIX)
|
36
|
-
|
37
|
-
BEARER = 'Bearer' unless const_defined?(:BEARER)
|
38
|
-
|
39
|
-
MEDIA_TYPE_JSON = 'application/json' unless const_defined?(:MEDIA_TYPE_JSON)
|
40
|
-
|
41
|
-
SIGNATURE_ALGORITHM = 'HmacSHA256' unless const_defined?(:SIGNATURE_ALGORITHM)
|
42
|
-
|
43
|
-
ALGORITHM = "algorithm=\"" unless const_defined?(:ALGORITHM)
|
44
|
-
|
45
|
-
SHA256 = 'SHA-256=' unless const_defined?(:SHA256)
|
46
|
-
|
47
|
-
CONTENT_TYPE = 'Content-Type' unless const_defined?(:CONTENT_TYPE)
|
48
|
-
|
49
|
-
USER_AGENT = 'User-Agent' unless const_defined?(:USER_AGENT)
|
50
|
-
|
51
|
-
USER_AGENT_VALUE = 'Mozilla/5.0' unless const_defined?(:USER_AGENT_VALUE)
|
52
|
-
|
53
|
-
KEY_ID = "keyid=\"" unless const_defined?(:KEY_ID)
|
54
|
-
|
55
|
-
HEADERS_PARAM = "headers=\"" unless const_defined?(:HEADERS_PARAM)
|
56
|
-
|
57
|
-
SIGNATURE_PARAM = "signature=\"" unless const_defined?(:SIGNATURE_PARAM)
|
58
|
-
|
59
|
-
AUTH_TYPE_HTTP = 'HTTP_SIGNATURE' unless const_defined?(:AUTH_TYPE_HTTP)
|
60
|
-
|
61
|
-
AUTH_TYPE_JWT = 'JWT' unless const_defined?(:AUTH_TYPE_JWT)
|
62
|
-
|
63
|
-
RUN_ENV_SANDBOX = 'CYBERSOURCE.ENVIRONMENT.SANDBOX' unless const_defined?(:RUN_ENV_SANDBOX)
|
64
|
-
|
65
|
-
RUN_ENV_PROD = 'CYBERSOURCE.ENVIRONMENT.PRODUCTION'unless const_defined?(:RUN_ENV_PROD)
|
66
|
-
|
67
|
-
SANDBOX_URL = 'apitest.cybersource.com' unless const_defined?(:SANDBOX_URL)
|
68
|
-
|
69
|
-
PRODUCTION_URL = 'api.cybersource.com' unless const_defined?(:PRODUCTION_URL)
|
70
|
-
|
71
|
-
# constants for fall back logic
|
72
|
-
|
73
|
-
DEFAULT_LOG_SIZE = '10485760' unless const_defined?(:DEFAULT_LOG_SIZE)
|
74
|
-
|
75
|
-
DEFAULT_PROXY_ADDRESS = 'userproxy.visa.com' unless const_defined?(:DEFAULT_PROXY_ADDRESS)
|
76
|
-
|
77
|
-
DEFAULT_PROXY_PORT = '443' unless const_defined?(:DEFAULT_PROXY_PORT)
|
78
|
-
|
79
|
-
DEFAULT_TIMEOUT = '1000' unless const_defined?(:DEFAULT_TIMEOUT)
|
80
|
-
|
81
|
-
DEFAULT_LOG_DIRECTORY = '../log' unless const_defined?(:DEFAULT_LOG_DIRECTORY)
|
82
|
-
|
83
|
-
DEFAULT_KEY_DIRECTORY = 'resource' unless const_defined?(:DEFAULT_KEY_DIRECTORY)
|
84
|
-
|
85
|
-
DEFAULT_LOGFILE_NAME = 'cybs' unless const_defined?(:DEFAULT_LOGFILE_NAME)
|
86
|
-
|
87
|
-
# Constant for Fall back logic and Exception Handling
|
88
|
-
|
89
|
-
REQUEST_JSON_ERROR = 'Request Json File missing. File Path :: ' unless const_defined?(:REQUEST_JSON_ERROR)
|
90
|
-
|
91
|
-
INVALID_ENABLE_LOG = 'EnableLog should be (True/False) in cybs.yml' unless const_defined?(:INVALID_ENABLE_LOG)
|
92
|
-
|
93
|
-
REFER_LOG = 'Please refer Log for details' unless const_defined?(:REFER_LOG)
|
94
|
-
|
95
|
-
MERCHANT_ID_NULL = 'MerchantID is mandatory' unless const_defined?(:MERCHANT_ID_NULL)
|
96
|
-
|
97
|
-
INCORRECT_KEY_PASS = 'The keyPass Entered is Incorrect' unless const_defined?(:INCORRECT_KEY_PASS)
|
98
|
-
|
99
|
-
AUTH_TYPE_MANDATORY= 'AuthenticationType is Mandatory' unless const_defined?(:AUTH_TYPE_MANDATORY)
|
100
|
-
|
101
|
-
MERCHANT_KEY_ID_MANDATORY = 'MerchantKeyId is Mandatory' unless const_defined?(:MERCHANT_KEY_ID_MANDATORY)
|
102
|
-
|
103
|
-
MERCHANT_SECRET_KEY_MANDATORY = 'MerchantSecretKey is Mandatory' unless const_defined?(:MERCHANT_SECRET_KEY_MANDATORY)
|
104
|
-
|
105
|
-
KEY_PASS_NULL = 'keyPass is empty, Assigining merchantID value' unless const_defined?(:KEY_PASS_NULL)
|
106
|
-
|
107
|
-
REQUEST_JSON_PATH_EMPTY = 'RequestJsonPath not provided. Using Default Value:'unless const_defined?(:REQUEST_JSON_PATH_EMPTY)
|
108
|
-
|
109
|
-
REQUEST_TYPE_EMPTY = 'RequestType Property of Merchant Config Not Set' unless const_defined?(:REQUEST_TYPE_EMPTY)
|
110
|
-
|
111
|
-
INVALID_REQUEST_TYPE_METHOD = 'Entered Request Type should be (GET/POST/PUT)' unless const_defined?(:INVALID_REQUEST_TYPE_METHOD)
|
112
|
-
|
113
|
-
INVALID_LOG_DIRECTORY = 'Entered LogDirectory is Incorrect. Using Default Path: ' unless const_defined?(:INVALID_LOG_DIRECTORY)
|
114
|
-
|
115
|
-
RUN_ENVIRONMENT_ERROR = 'Entered RunEnvironment is Incorrect.' unless const_defined?(:RUN_ENVIRONMENT_ERROR)
|
116
|
-
|
117
|
-
PROPERTY_FILE_NOT_FOUND = 'Cybs.yml file not found' unless const_defined?(:PROPERTY_FILE_NOT_FOUND)
|
118
|
-
|
119
|
-
ERROR_PREFIX = 'Error: ' unless const_defined?(:ERROR_PREFIX)
|
120
|
-
|
121
|
-
WARNING_PREFIX = 'Warning: ' unless const_defined?(:WARNING_PREFIX)
|
122
|
-
|
123
|
-
HIDDEN_MERCHANT_PROPERTIES = 'merchantID,merchantKeyId,merchantsecretKey,keyAlias,keyPass' unless const_defined?(:HIDDEN_MERCHANT_PROPERTIES)
|
124
|
-
|
125
|
-
RUN_ENVIRONMENT = 'RunEnvironment is Mandatory' unless const_defined?(:RUN_ENVIRONMENT)
|
126
|
-
|
127
|
-
KEY_DIRECTORY_EMPTY = 'KeysDirectory not provided. Using Default Path:' unless const_defined?(:KEY_DIRECTORY_EMPTY)
|
128
|
-
|
129
|
-
FILE_NOT_FOUND = 'File not found, Re-Enter path/file name, Entered path/file name :: ' unless const_defined?(:FILE_NOT_FOUND)
|
130
|
-
|
131
|
-
AUTH_ERROR = 'Check Authentication Type (HTTP_Signature/JWT) in cybs.yml.' unless const_defined?(:AUTH_ERROR)
|
132
|
-
|
133
|
-
KEY_FILE_NAME_NULL_EMPTY = 'KeyFilename Empty/Null. Assigining merchantID value' unless const_defined?(:KEY_FILE_NAME_NULL_EMPTY)
|
134
|
-
|
135
|
-
KEY_ALIAS_NULL_EMPTY = 'KeyAlias Empty/Null. Assigining merchantID value' unless const_defined?(:KEY_ALIAS_NULL_EMPTY)
|
136
|
-
|
137
|
-
INCORRECT_KEY_ALIAS = 'The Entered KeyAlias is Incorrect. Assigining merchantID value' unless const_defined?(:INCORRECT_KEY_ALIAS)
|
138
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require_relative './Constants.rb'
|
3
|
-
public
|
4
|
-
# Method for reading Cybs.yml file
|
5
|
-
class PropertiesUtil
|
6
|
-
def getCybsProp()
|
7
|
-
# Give the path of cybs properties file which needs to be read.
|
8
|
-
cybs_path = '../resource/cybs.yml'
|
9
|
-
if File.exist?(cybs_path)
|
10
|
-
# Reading Merchant Config from Cybs.yml File"
|
11
|
-
cybsproperty_obj = YAML.load(File.read(cybs_path))
|
12
|
-
return cybsproperty_obj
|
13
|
-
elsif !File.exist?(cybs_path)
|
14
|
-
raise Constants::ERROR_PREFIX + Constants::PROPERTY_FILE_NOT_FOUND
|
15
|
-
end
|
16
|
-
rescue StandardError => err
|
17
|
-
puts err.message
|
18
|
-
exit!
|
19
|
-
end
|
20
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
public
|
2
|
-
class Utility
|
3
|
-
def getResponseCodeMessage(responseCode)
|
4
|
-
responseCode = responseCode.to_s
|
5
|
-
case responseCode
|
6
|
-
when "200"
|
7
|
-
tempResponseCodeMessage = "Transcation Successful"
|
8
|
-
when "201"
|
9
|
-
tempResponseCodeMessage = "Transcation Successful"
|
10
|
-
when "400"
|
11
|
-
tempResponseCodeMessage = "Bad Request"
|
12
|
-
when "401"
|
13
|
-
tempResponseCodeMessage = "Authentication Failed"
|
14
|
-
when "404"
|
15
|
-
tempResponseCodeMessage = "Not Found"
|
16
|
-
when "403"
|
17
|
-
tempResponseCodeMessage = "Forbidden"
|
18
|
-
when "500"
|
19
|
-
tempResponseCodeMessage = "Internal Server Error"
|
20
|
-
when "502"
|
21
|
-
tempResponseCodeMessage = "Bad Gateway"
|
22
|
-
when "503"
|
23
|
-
tempResponseCodeMessage = "Service Unavailable"
|
24
|
-
when "504"
|
25
|
-
tempResponseCodeMessage = "Gateway Timeout"
|
26
|
-
else
|
27
|
-
tempResponseCodeMessage= ''
|
28
|
-
end
|
29
|
-
return tempResponseCodeMessage
|
30
|
-
end
|
31
|
-
end
|