Skip to content

Commit c5148cf

Browse files
committed
Update to latest version of SDK
1 parent 623513f commit c5148cf

23 files changed

+244
-107
lines changed

Logging.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[![Generic badge](https://img.shields.io/badge/LOGGING-NEW-GREEN.svg)](https://shields.io/)
2+
3+
# Logging in CyberSource REST Client SDK (Ruby)
4+
5+
Since v0.0.38, a new logging framework has been introduced in the SDK. This new logging framework makes use of Ruby's logger package, and standardizes the logging so that it can be integrated with the logging in the client application.
6+
7+
## Ruby's logger package Configuration
8+
9+
In order to leverage the new logging framework, the following configuration settings may be added to the merchant configuration as part of **`LogConfiguration`**:
10+
11+
* enableLog
12+
* loggingLevel
13+
* logDirectory
14+
* logFilename
15+
* maxLogSize
16+
* maxLogFiles
17+
* enableMasking
18+
19+
In our [sample Configuration.py](https://github.com/CyberSource/cybersource-rest-samples-ruby/blob/master/data/Configuration.rb) file, the following lines have been added to support this new framework:
20+
21+
```ruby
22+
enableLog=true
23+
loggingLevel='DEBUG'
24+
logDirectory='log'
25+
logFilename='cybs'
26+
maxLogSize=10485760
27+
maxLogFiles=5
28+
enableMasking=true
29+
...
30+
log_config = {}
31+
log_config['enableLog'] = enableLog
32+
log_config['loggingLevel'] = loggingLevel
33+
log_config['logDirectory'] = logDirectory
34+
log_config['logFilename'] = logFilename
35+
log_config['maxLogSize'] = maxLogSize
36+
log_config['maxLogFiles'] = maxLogFiles
37+
log_config['enableMasking'] = enableMasking
38+
configurationDictionary['logConfiguration'] = log_config
39+
```
40+
41+
### Important Notes
42+
43+
The variable `enableMasking` needs to be set to `true` if sensitive data in the request/response should be hidden/masked.
44+
45+
Sensitive data fields are listed below:
46+
47+
* Card Security Code
48+
* Card Number
49+
* Any field with `number` in the name
50+
* Card Expiration Month
51+
* Card Expiration Year
52+
* Account
53+
* Routing Number
54+
* Email
55+
* First Name & Last Name
56+
* Phone Number
57+
* Type
58+
* Token
59+
* Signature

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,11 @@ with the following code:
136136
## API Reference
137137

138138
The [API Reference Guide](http://developer.cybersource.com/api/reference) provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request using this SDK.
139+
140+
### Logging
141+
142+
[![Generic badge](https://img.shields.io/badge/LOGGING-NEW-GREEN.svg)](https://shields.io/)
143+
144+
Since v0.0.38, a new logging framework has been introduced in the SDK. This new logging framework makes use of Ruby's logger package, and standardizes the logging so that it can be integrated with the logging in the client application.
145+
146+
More information about this new logging framework can be found in this file : [Logging.md](Logging.md)

Samples/Authentication/data/Configuration.rb

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ def merchantConfigProp()
55
runEnvironment='apitest.cybersource.com'
66
timeout=1000 #In Milliseconds
77
authenticationType='JWT' #'HTTP_Signature'
8-
logDirectory='./log'
98
jsonFilePath='./resource/request.json'
10-
logSize=5000
11-
enableLog=true
129
#proxyAddress='userproxy.visa.com'
1310
#proxyPort=443
1411
# HTTP Parameters
@@ -23,17 +20,30 @@ def merchantConfigProp()
2320
# MetaKey Params
2421
useMetaKey = false
2522
portfolioID = ''
26-
23+
24+
enableLog=true
25+
loggingLevel = 'DEBUG'
26+
logDirectory='./log'
2727
logFilename='Cybs'
28+
maxLogSize=5000
29+
maxLogFiles=5
30+
enableMasking=true
31+
32+
logConfiguration={}
33+
logConfiguration['enableLog']=enableLog
34+
logConfiguration['loggingLevel']=loggingLevel
35+
logConfiguration['logDirectory']=logDirectory
36+
logConfiguration['logFilename']=logFilename
37+
logConfiguration['maxLogSize']=maxLogSize
38+
logConfiguration['maxLogFiles']=maxLogFiles
39+
logConfiguration['enableMasking']=enableMasking
40+
2841
configurationDictionary={}
2942
configurationDictionary['merchantID']=merchantId
3043
configurationDictionary['runEnvironment']=runEnvironment
3144
configurationDictionary['timeout']=timeout
3245
configurationDictionary['authenticationType']=authenticationType
33-
configurationDictionary['logDirectory']=logDirectory
3446
configurationDictionary['jsonFilePath']=jsonFilePath
35-
configurationDictionary['logSize']=logSize
36-
configurationDictionary['enableLog']=enableLog
3747
# configurationDictionary['proxyPort']=proxyPort
3848
configurationDictionary['merchantsecretKey']=merchantSecretKey
3949
configurationDictionary['merchantKeyId']=merchantKeyId
@@ -43,7 +53,7 @@ def merchantConfigProp()
4353
configurationDictionary['useMetaKey'] = useMetaKey
4454
configurationDictionary['portfolioID'] = portfolioID
4555
configurationDictionary['keyFilename'] = keyFilename
46-
configurationDictionary['logFilename'] = logFilename
56+
configurationDictionary['logConfiguration']=logConfiguration
4757
return configurationDictionary
4858
end
4959
end

Samples/Authentication/resource/cybs.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
#EBC portal Values
1919
merchantKeyId : "08c94330-f618-42a3-b09d-e1e43be5efda"
2020
merchantsecretKey : "yBJxy6LjM2TmcPGu+GaJrHtkke25fPpUX+UY6/L/1tE="
21-
#Logging to be enabled or not [true/false].
22-
enableLog : true
23-
#Log directory Path
24-
logDirectory : F:/Desktop/Log
25-
#Enter only file name, do not enter the extension type like .log, .txt etc.
26-
logFilename : "Cybs"
27-
#Log file size in KB "5K" or MB as "5M".
28-
logSize : 10485760
2921
#Proxy Setup
3022
# proxyAddress : "userproxy.visa.com"
31-
# proxyPort :
23+
# proxyPort :
24+
logConfiguration:
25+
enableLog: true
26+
loggingLevel: 'DEBUG'
27+
logDirectory: './log'
28+
logFilename: 'Cybs'
29+
maxLogSize: 10425760
30+
maxLogFiles: 5
31+
enableMasking: true

Samples/Authentication/src/DeleteGenerateHeaders.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main()
2020
merchantConfigObj = Merchantconfig.new cybsPropertyobj
2121

2222
# creating Logger Object
23-
logObj = Log.new merchantConfigObj.logDirectory,merchantConfigObj.logFilename,merchantConfigObj.logSize,merchantConfigObj.enableLog
23+
logObj = Log.new merchantConfigObj.log_config, "DeleteGenerateHeaders"
2424

2525
#setting requestType,requestTarget,requestUrl
2626
merchantConfigObj.requestType = @@request_type
@@ -50,15 +50,15 @@ def main()
5050
logObj.logger.info("Date : " + gmtDateTime)
5151
puts "Date : " + gmtDateTime
5252

53-
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime,logObj)
53+
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime)
5454
logObj.logger.info("Host : " + merchantConfigObj.requestHost)
5555
puts "Host : " + merchantConfigObj.requestHost
5656

5757
logObj.logger.info("Signature Header : " + tempSig)
5858
puts "Signature Header : " + tempSig
5959
else
6060
#JWT Token
61-
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime,logObj)
61+
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime)
6262
puts "Authorization,Bearer : " + tempSig
6363
logObj.logger.info("Authorization,Bearer : " + tempSig)
6464
end

Samples/Authentication/src/DeleteMethod.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def main
1919
# creating MerchantConfig Object
2020
merchantconfig_obj = Merchantconfig.new(cybsproperty_obj)
2121

22-
logObj = Log.new merchantconfig_obj.logDirectory,merchantconfig_obj.logFilename,merchantconfig_obj.logSize,merchantconfig_obj.enableLog
22+
logObj = Log.new merchantconfig_obj.log_config, 'DeleteMethod'
2323
# setting requestTarget,requestUrl,requestType to merchantConfig Object
2424
merchantconfig_obj.requestTarget = @@request_target
2525
# Give the url path to where the data needs to be authenticated.
@@ -28,7 +28,7 @@ def main
2828
merchantconfig_obj.requestType = @@request_type
2929

3030
# Calling APISDK, ApiController
31-
response_code, response_body, vc_correlationid = APIController.new.payment_delete(merchantconfig_obj, logObj)
31+
response_code, response_body, vc_correlationid = APIController.new.payment_delete(merchantconfig_obj)
3232
puts 'v-c-correlation-id:' + vc_correlationid
3333
puts 'Response Code:' + response_code
3434
puts 'Response Body:' + response_body

Samples/Authentication/src/GetGenerateHeaders.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def main()
2424
merchantConfigObj = Merchantconfig.new cybsPropertyobj
2525

2626
# creating Logger Object
27-
logObj = Log.new merchantConfigObj.logDirectory,merchantConfigObj.logFilename,merchantConfigObj.logSize,merchantConfigObj.enableLog
27+
logObj = Log.new merchantConfigObj.log_config, 'GetGenerateHeaders'
2828

2929
#setting requestType,requestTarget,requestUrl
3030
merchantConfigObj.requestType = @@request_type
@@ -55,15 +55,15 @@ def main()
5555
logObj.logger.info("Date : " + gmtDateTime)
5656
puts "Date : " + gmtDateTime
5757

58-
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime,logObj)
58+
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime)
5959
logObj.logger.info("Host : " + merchantConfigObj.requestHost)
6060
puts "Host : " + merchantConfigObj.requestHost
6161

6262
logObj.logger.info("Signature Header : " + tempSig)
6363
puts "Signature Header : " + tempSig
6464
else
6565
#JWT Token
66-
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime,logObj)
66+
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime)
6767
puts "Authorization,Bearer : " + tempSig
6868
logObj.logger.info("Authorization,Bearer : " + tempSig)
6969
end

Samples/Authentication/src/GetMethod.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def main
1818
cybsproperty_obj = PropertiesUtil.new.getCybsProp('resource/cybs.yml')
1919
merchantconfig_obj = Merchantconfig.new(cybsproperty_obj)
2020

21-
logObj = Log.new merchantconfig_obj.logDirectory,merchantconfig_obj.logFilename,merchantconfig_obj.logSize,merchantconfig_obj.enableLog
21+
logObj = Log.new merchantconfig_obj.log_config, 'GetMethod'
2222
# Set Request Type into the merchant config object.
2323
merchantconfig_obj.requestType = @@request_type
2424
# Set Request Target into the merchant config object.
@@ -28,7 +28,7 @@ def main
2828
# Set URL into the merchant config object.
2929
merchantconfig_obj.requestUrl = url
3030
# Calling APISDK, Apisdk.controller.
31-
response_code, response_body, vc_correlationid = APIController.new.payment_get(merchantconfig_obj, logObj)
31+
response_code, response_body, vc_correlationid = APIController.new.payment_get(merchantconfig_obj)
3232
# Display response message and Headers in console.
3333
puts 'v-c-correlation-id:' + vc_correlationid
3434
puts 'Response Code:' + response_code

Samples/Authentication/src/GetObjectMethod.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main
2020
cybsPropertyobj = Configuration.new.merchantConfigProp
2121
merchantconfig_obj = Merchantconfig.new cybsPropertyobj
2222

23-
logObj = Log.new merchantconfig_obj.logDirectory,merchantconfig_obj.logFilename,merchantconfig_obj.logSize,merchantconfig_obj.enableLog
23+
logObj = Log.new merchantconfig_obj.log_config, 'GetObjectMethod'
2424
# Set Request Type into the merchant config object.
2525
merchantconfig_obj.requestType = @@request_type
2626
# Set Request Target into the merchant config object.
@@ -30,7 +30,7 @@ def main
3030
# Set URL into the merchant config object.
3131
merchantconfig_obj.requestUrl = url
3232
# Calling APISDK, Apisdk.controller.
33-
response_code, response_body, vc_correlationid = APIController.new.payment_get(merchantconfig_obj, logObj)
33+
response_code, response_body, vc_correlationid = APIController.new.payment_get(merchantconfig_obj)
3434
# Display response message and Headers in console.
3535
puts 'v-c-correlation-id:' + vc_correlationid
3636
puts 'Response Code:' + response_code

Samples/Authentication/src/PostGenerateHeaders.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def main()
2323
merchantConfigObj = Merchantconfig.new cybsPropertyobj
2424

2525
# creating Logger Object
26-
logObj = Log.new merchantConfigObj.logDirectory,merchantConfigObj.logFilename,merchantConfigObj.logSize,merchantConfigObj.enableLog
26+
logObj = Log.new merchantConfigObj.log_config, 'PostGenerateHeaders'
2727

2828
#setting requestType,requestTarget,requestUrl
2929
merchantConfigObj.requestType = @@request_type
@@ -55,20 +55,20 @@ def main()
5555
maskedRequestBody = Masking.new.maskPayload(merchantConfigObj.requestJsonData)
5656
logObj.logger.info("Request Body: " + JSON.generate(maskedRequestBody))
5757

58-
digest = DigestGeneration.new.generateDigest(merchantConfigObj.requestJsonData,logObj)
58+
digest = DigestGeneration.new.generateDigest(merchantConfigObj.requestJsonData)
5959
digest = Constants::SHA256 + digest
6060
logObj.logger.info("Digest : " + digest)
6161
puts "Digest : " + digest
6262

63-
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime,logObj)
63+
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime)
6464
logObj.logger.info("Host : " + merchantConfigObj.requestHost)
6565
puts "Host : " + merchantConfigObj.requestHost
6666

6767
logObj.logger.info("Signature Header : " + tempSig)
6868
puts "Signature Header : " + tempSig
6969
else
7070
#JWT Token
71-
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime,logObj)
71+
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime)
7272
puts "Authorization,Bearer : " + tempSig
7373
logObj.logger.info("Authorization,Bearer : " + tempSig)
7474
end

Samples/Authentication/src/PostMethod.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def main
1818
cybsproperty_obj = PropertiesUtil.new.getCybsProp('resource/cybs.yml')
1919
merchantconfig_obj = Merchantconfig.new(cybsproperty_obj)
2020

21-
logObj = Log.new merchantconfig_obj.logDirectory,merchantconfig_obj.logFilename,merchantconfig_obj.logSize,merchantconfig_obj.enableLog
21+
logObj = Log.new merchantconfig_obj.log_config, 'PostMethod'
2222
# Set Request Type into the merchant config object.
2323
merchantconfig_obj.requestType = @@request_type
2424
# Set Request Target into the merchant config object.
@@ -30,7 +30,7 @@ def main
3030
# SetrequestJsonDataURL into the merchant config object.
3131
merchantconfig_obj.requestJsonData = RequestData.new.jsonFileData(@@requestJsonPath)
3232
# Calling APISDK, Apisdk.Controller
33-
response_code, response_body, vc_correlationid = APIController.new.payment_post(merchantconfig_obj, logObj)
33+
response_code, response_body, vc_correlationid = APIController.new.payment_post(merchantconfig_obj)
3434
# Display response message and Headers in console.
3535
puts 'v-c-correlation-id:' + vc_correlationid
3636
puts 'Response Code:' + response_code

Samples/Authentication/src/PostObjectMethod.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def main()
2020
cybsPropertyobj = Configuration.new.merchantConfigProp
2121
merchantConfigObj = Merchantconfig.new cybsPropertyobj
2222

23-
logObj = Log.new merchantConfigObj.logDirectory,merchantConfigObj.logFilename,merchantConfigObj.logSize,merchantConfigObj.enableLog
23+
logObj = Log.new merchantConfigObj.log_config, 'PostObjectMethod'
2424
# setting requestTarget to merchant
2525
merchantConfigObj.requestTarget = @@request_target
2626
merchantConfigObj.requestJsonData = RequestData.new.samplePaymentsData()
@@ -29,7 +29,7 @@ def main()
2929
merchantConfigObj.requestType = @@request_type
3030
merchantConfigObj.requestUrl = url
3131
# Calling APISDK, ApiController
32-
responsecode,responseBody,v_c_correlationId = APIController.new.payment_post(merchantConfigObj, logObj)
32+
responsecode,responseBody,v_c_correlationId = APIController.new.payment_post(merchantConfigObj)
3333
puts "v-c-correlation-id:" + v_c_correlationId
3434
puts "Response Code:" + responsecode
3535
puts "Response Body:" + responseBody

Samples/Authentication/src/PutGenerateHeaders.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def main()
2323
merchantConfigObj = Merchantconfig.new cybsPropertyobj
2424

2525
# creating Logger Object
26-
logObj = Log.new merchantConfigObj.logDirectory,merchantConfigObj.logFilename,merchantConfigObj.logSize,merchantConfigObj.enableLog
26+
logObj = Log.new merchantConfigObj.log_config, 'PutGenerateHeaders'
2727

2828
#setting requestType,requestTarget,requestUrl
2929
merchantConfigObj.requestType = @@request_type
@@ -55,20 +55,20 @@ def main()
5555
maskedRequestBody = Masking.new.maskPayload(merchantConfigObj.requestJsonData)
5656
logObj.logger.info("Request Body: " + JSON.generate(maskedRequestBody))
5757

58-
digest = DigestGeneration.new.generateDigest(merchantConfigObj.requestJsonData,logObj)
58+
digest = DigestGeneration.new.generateDigest(merchantConfigObj.requestJsonData)
5959
digest = Constants::SHA256 + digest
6060
logObj.logger.info("Digest : " + digest)
6161
puts "Digest : " + digest
6262

63-
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime,logObj)
63+
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime)
6464
logObj.logger.info("Host : " + merchantConfigObj.requestHost)
6565
puts "Host : " + merchantConfigObj.requestHost
6666

6767
logObj.logger.info("Signature Header : " + tempSig)
6868
puts "Signature Header : " + tempSig
6969
else
7070
#JWT Token
71-
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime,logObj)
71+
tempSig = Authorization.new.getToken(merchantConfigObj,gmtDateTime)
7272
puts "Authorization,Bearer : " + tempSig
7373
logObj.logger.info("Authorization,Bearer : " + tempSig)
7474
end

Samples/Authentication/src/PutMethod.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def main
1818
cybsproperty_obj = PropertiesUtil.new.getCybsProp('resource/cybs.yml')
1919
merchantconfig_obj = Merchantconfig.new(cybsproperty_obj)
2020

21-
logObj = Log.new merchantconfig_obj.logDirectory,merchantconfig_obj.logFilename,merchantconfig_obj.logSize,merchantconfig_obj.enableLog
21+
logObj = Log.new merchantconfig_obj.log_config, 'PutMethod'
2222
# Set Request Type into the merchant config object.
2323
merchantconfig_obj.requestType = @@request_type
2424
# Set Request Target into the merchant config object.
@@ -30,7 +30,7 @@ def main
3030
# SetrequestJsonDataURL into the merchant config object.
3131
merchantconfig_obj.requestJsonData=RequestData.new.jsonFileData(@@requestJsonPath)
3232
# Calling APISDK, Apisdk.Controller
33-
response_code, response_body, vc_correlationid = APIController.new.payment_put(merchantconfig_obj, logObj)
33+
response_code, response_body, vc_correlationid = APIController.new.payment_put(merchantconfig_obj)
3434
# Display response message and Headers in console.
3535
puts 'v-c-correlation-id:' + vc_correlationid
3636
puts 'Response Code:' + response_code

0 commit comments

Comments
 (0)