Skip to content

Commit 2bea814

Browse files
authored
Merge pull request #95 from CyberSource/july-2022
July 2022
2 parents 26f153a + 21130e2 commit 2bea814

16 files changed

+160
-20
lines changed

docs/MitVoidRequest.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
66
**clientReferenceInformation** | [**Ptsv2paymentsClientReferenceInformation**](Ptsv2paymentsClientReferenceInformation.md) | | [optional]
77
**paymentInformation** | [**Ptsv2paymentsidvoidsPaymentInformation**](Ptsv2paymentsidvoidsPaymentInformation.md) | | [optional]
8+
**orderInformation** | [**Ptsv2paymentsidvoidsOrderInformation**](Ptsv2paymentsidvoidsOrderInformation.md) | | [optional]
89

910

docs/PtsV2PaymentsRefundPost201ResponseProcessorInformation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ Name | Type | Description | Notes
99
**merchantNumber** | **String** | Identifier that was assigned to you by your acquirer. This value must be printed on the receipt. #### Returned by Authorizations and Credits. This reply field is only supported by merchants who have installed client software on their POS terminals and use these processors: - American Express Direct - Credit Mutuel-CIC - FDC Nashville Global - OmniPay Direct - SIX | [optional]
1010
**responseCode** | **String** | For most processors, this is the error message sent directly from the bank. Returned only when the processor returns this value. **Important** Do not use this field to evaluate the result of the authorization. #### PIN debit Response value that is returned by the processor or bank. **Important** Do not use this field to evaluate the results of the transaction request. Returned by PIN debit credit, PIN debit purchase, and PIN debit reversal. #### AIBMS If this value is `08`, you can accept the transaction if the customer provides you with identification. #### Atos This value is the response code sent from Atos and it might also include the response code from the bank. Format: `aa,bb` with the two values separated by a comma and where: - `aa` is the two-digit error message from Atos. - `bb` is the optional two-digit error message from the bank. #### Comercio Latino This value is the status code and the error or response code received from the processor separated by a colon. Format: [status code]:E[error code] or [status code]:R[response code] Example `2:R06` #### JCN Gateway Processor-defined detail error code. The associated response category code is in the `processorInformation.responseCategoryCode` field. String (3) | [optional]
1111
**achVerification** | [**PtsV2PaymentsPost201ResponseProcessorInformationAchVerification**](PtsV2PaymentsPost201ResponseProcessorInformationAchVerification.md) | | [optional]
12+
**networkTransactionId** | **String** | Same value as `processorInformation.transactionId` | [optional]
1213

1314

generator/cybersource-javascript-template/index.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@
9898
exports.LogConfiguration = require('./authentication/logging/LogConfiguration.js');
9999
exports.SensitiveDataTags = require('./authentication/logging/SensitiveDataTags.js');
100100
exports.SensitiveDataMasker = require('./authentication/logging/SensitiveDataMasker.js');
101-
101+
exports.ExternalLoggerWrapper = require('./authentication/logging/ExternalLoggerWrapper.js');
102102
return exports;<={{ }}=>
103103
}));

generator/cybersource-rest-spec.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14468,6 +14468,10 @@
1446814468
"description": "Raw results from the ACH verification service.\nFor details about this service and the possible values for the raw results, see \"ACH Verification\" and \"Verification Codes\" in the [Electronic Check Services Using the SCMP API](https://apps.cybersource.com/library/documentation/dev_guides/EChecks_SCMP_API/html/).\n"
1446914469
}
1447014470
}
14471+
},
14472+
"networkTransactionId": {
14473+
"type": "string",
14474+
"description": "Same value as `processorInformation.transactionId`"
1447114475
}
1447214476
}
1447314477
},
@@ -16865,6 +16869,10 @@
1686516869
"description": "Raw results from the ACH verification service.\nFor details about this service and the possible values for the raw results, see \"ACH Verification\" and \"Verification Codes\" in the [Electronic Check Services Using the SCMP API](https://apps.cybersource.com/library/documentation/dev_guides/EChecks_SCMP_API/html/).\n"
1686616870
}
1686716871
}
16872+
},
16873+
"networkTransactionId": {
16874+
"type": "string",
16875+
"description": "Same value as `processorInformation.transactionId`"
1686816876
}
1686916877
}
1687016878
},
@@ -19551,6 +19559,10 @@
1955119559
"description": "Raw results from the ACH verification service.\nFor details about this service and the possible values for the raw results, see \"ACH Verification\" and \"Verification Codes\" in the [Electronic Check Services Using the SCMP API](https://apps.cybersource.com/library/documentation/dev_guides/EChecks_SCMP_API/html/).\n"
1955219560
}
1955319561
}
19562+
},
19563+
"networkTransactionId": {
19564+
"type": "string",
19565+
"description": "Same value as `processorInformation.transactionId`"
1955419566
}
1955519567
}
1955619568
},
@@ -21521,6 +21533,26 @@
2152121533
}
2152221534
}
2152321535
}
21536+
},
21537+
"orderInformation": {
21538+
"type": "object",
21539+
"properties": {
21540+
"amountDetails": {
21541+
"type": "object",
21542+
"properties": {
21543+
"totalAmount": {
21544+
"type": "string",
21545+
"maxLength": 19,
21546+
"description": "Grand total for the order. This value cannot be negative. You can include a decimal point (.), but no other special characters.\nCyberSource truncates the amount to the correct number of decimal places.\n\n**Note** For CTV, FDCCompass, Paymentech processors, the maximum length for this field is 12.\n\n**Important** Some processors have specific requirements and limitations, such as maximum amounts and maximum field lengths. For details, see:\n- \"Authorization Information for Specific Processors\" in the [Credit Card Services Using the SCMP API Guide](https://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_SCMP_API/html/).\n- \"Capture Information for Specific Processors\" in the [Credit Card Services Using the SCMP API Guide](https://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_SCMP_API/html/).\n- \"Credit Information for Specific Processors\" in the [Credit Card Services Using the SCMP API Guide](https://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_SCMP_API/html/).\n\nIf your processor supports zero amount authorizations, you can set this field to 0 for the authorization to check if the card is lost or stolen. For details, see \"Zero Amount Authorizations,\" \"Credit Information for Specific Processors\" in [Credit Card Services Using the SCMP API.](https://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_SCMP_API/html/)\n\n#### Card Present\nRequired to include either this field or `orderInformation.lineItems[].unitPrice` for the order.\n\n#### Invoicing\nRequired for creating a new invoice.\n\n#### PIN Debit\nAmount you requested for the PIN debit purchase. This value is returned for partial authorizations. The issuing bank can approve a partial amount if the balance on the debit card is less than the requested transaction amount.\n\nRequired field for PIN Debit purchase and PIN Debit credit requests.\nOptional field for PIN Debit reversal requests.\n\n#### GPX\nThis field is optional for reversing an authorization or credit; however, for all other processors, these fields are required.\n\n#### DCC with a Third-Party Provider\nSet this field to the converted amount that was returned by the DCC provider. You must include either this field or the 1st line item in the order and the specific line-order amount in your request. For details, see `grand_total_amount` field description in [Dynamic Currency Conversion For First Data Using the SCMP API](http://apps.cybersource.com/library/documentation/dev_guides/DCC_FirstData_SCMP/DCC_FirstData_SCMP_API.pdf).\n\n#### FDMS South\nIf you accept IDR or CLP currencies, see the entry for FDMS South in \"Authorization Information for Specific Processors\" of the [Credit Card Services Using the SCMP API.](https://apps.cybersource.com/library/documentation/dev_guides/CC_Svcs_SCMP_API/html/)\n\n#### DCC for First Data\nNot used.\n"
21547+
},
21548+
"currency": {
21549+
"type": "string",
21550+
"maxLength": 3,
21551+
"description": "Currency used for the order. Use the three-character [ISO Standard Currency Codes.](http://apps.cybersource.com/library/documentation/sbc/quickref/currencies.pdf)\n\n#### Used by\n**Authorization**\nRequired field.\n\n**Authorization Reversal**\nFor an authorization reversal (`reversalInformation`) or a capture (`processingOptions.capture` is set to `true`), you must use the same currency that you used in your payment authorization request.\n\n#### PIN Debit\nCurrency for the amount you requested for the PIN debit purchase. This value is returned for partial authorizations. The issuing bank can approve a partial amount if the balance on the debit card is less than the requested transaction amount. For the possible values, see the [ISO Standard Currency Codes](https://developer.cybersource.com/library/documentation/sbc/quickref/currencies.pdf).\nReturned by PIN debit purchase.\n\nFor PIN debit reversal requests, you must use the same currency that was used for the PIN debit purchase or PIN debit credit that you are reversing.\nFor the possible values, see the [ISO Standard Currency Codes](https://developer.cybersource.com/library/documentation/sbc/quickref/currencies.pdf).\n\nRequired field for PIN Debit purchase and PIN Debit credit requests.\nOptional field for PIN Debit reversal requests.\n\n#### GPX\nThis field is optional for reversing an authorization or credit.\n\n#### DCC for First Data\nYour local currency. For details, see the `currency` field description in [Dynamic Currency Conversion For First Data Using the SCMP API](http://apps.cybersource.com/library/documentation/dev_guides/DCC_FirstData_SCMP/DCC_FirstData_SCMP_API.pdf).\n\n#### Tax Calculation\nRequired for international tax and value added tax only.\nOptional for U.S. and Canadian taxes.\nYour local currency.\n"
21552+
}
21553+
}
21554+
}
21555+
}
2152421556
}
2152521557
},
2152621558
"example": {

generator/cybersource_node_sdk_gen.bat

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ REM Command to generate SDK
1212

1313
java -jar swagger-codegen-cli-2.3.0.jar generate -t cybersource-javascript-template -i cybersource-rest-spec.json -l javascript -o ../ -c cybersource-node-config.json
1414

15-
powershell -Command "(Get-Content ..\src\Api\SecureFileShareApi.js) | ForEach-Object { $_ -replace 'contentTypes = \[''application/json;charset=utf-8', 'contentTypes = [''*/*' } | Set-Content ..\src\Api\SecureFileShareApi.js"
15+
powershell -Command "(Get-Content ..\src\Api\SecureFileShareApi.js) | ForEach-Object { $_ -replace 'contentTypes = \[''\*_\/_\*;charset=utf-8', 'contentTypes = [''*/*;charset=utf-8' } | Set-Content ..\src\Api\SecureFileShareApi.js"
16+
17+
powershell -Command "(Get-Content ..\docs\SecureFileShareApi.md) | ForEach-Object { $_ -replace '\*\*Content-Type\*\*: \*_\/_\*;charset=utf-8', '**Content-Type**: */*;charset=utf-8' } | Set-Content ..\docs\SecureFileShareApi.md"
1618

1719
git checkout ..\README.md
1820

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cybersource-rest-client",
3-
"version": "0.0.39",
3+
"version": "0.0.40",
44
"description": "Node.js SDK for the CyberSource REST API",
55
"author": "developer@cybersource.com",
66
"license": "CyberSource",

src/authentication/core/MerchantConfig.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,9 @@ MerchantConfig.prototype.defaultPropValues = function defaultPropValues() {
526526

527527
return merchantMap.toObject();
528528
}
529-
logger.clear();
529+
if(!this.logConfiguration.isExternalLoggerSet){
530+
logger.clear();
531+
}
530532
}
531533

532534
module.exports = MerchantConfig;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'use strict'
2+
3+
class ExternalLoggerWrapper{
4+
5+
extLogger;
6+
7+
constructor(externalLogger) {
8+
this.extLogger = externalLogger;
9+
}
10+
11+
getLogger(){
12+
return this.extLogger;
13+
}
14+
15+
isLoggerEmpty(){
16+
if(this.extLogger === undefined)
17+
return false;
18+
return true;
19+
}
20+
}
21+
22+
module.exports = ExternalLoggerWrapper;

src/authentication/logging/LogConfiguration.js

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
'use strict';
22

33
var Constants = require('../util/Constants');
4+
const ExternalLoggerWrapper = require('../logging/ExternalLoggerWrapper');
5+
const ApiException = require('../util/ApiException');
46

57
class LogConfiguration {
68
enableLog;
@@ -10,6 +12,8 @@ class LogConfiguration {
1012
loggingLevel;
1113
maxLogFiles;
1214
enableMasking;
15+
hasExternalLogger;
16+
externalLogger;
1317

1418
constructor(logConfig) {
1519
this.setLogEnable(logConfig.enableLog);
@@ -19,6 +23,8 @@ class LogConfiguration {
1923
this.setLoggingLevel(logConfig.loggingLevel);
2024
this.setMaxLogFiles(logConfig.maxLogFiles);
2125
this.setMaskingEnabled(logConfig.enableMasking);
26+
this.setHasExternalLogger(logConfig.hasExternalLogger);
27+
this.setExternalLogger(logConfig.externalLogger);
2228
}
2329

2430
isLogEnabled() {
@@ -43,6 +49,22 @@ class LogConfiguration {
4349
this.enableMasking = enableMaskingValue;
4450
}
4551

52+
setHasExternalLogger(hasExternalLogger){
53+
this.hasExternalLogger = hasExternalLogger;
54+
}
55+
56+
isExternalLoggerSet(){
57+
return this.hasExternalLogger;
58+
}
59+
60+
setExternalLogger(externalLogger){
61+
this.externalLogger = externalLogger;
62+
}
63+
64+
getExternalLogger(){
65+
return this.externalLogger;
66+
}
67+
4668
getLogDirectory () {
4769
return this.logDirectory;
4870
}
@@ -64,7 +86,7 @@ class LogConfiguration {
6486
setLogFileName (logFileNameValue) {
6587
this.logFileName = logFileNameValue;
6688
}
67-
89+
6890
getLogFileMaxSize () {
6991
return this.logFileMaxSize;
7092
}
@@ -90,7 +112,7 @@ class LogConfiguration {
90112
getMaxLogFiles () {
91113
return this.maxLogFiles;
92114
}
93-
115+
94116
/**
95117
* @param {any} maxLogFilesValue
96118
*/
@@ -99,6 +121,19 @@ class LogConfiguration {
99121
}
100122

101123
getDefaultLoggingProperties(warningMessage) {
124+
125+
if(typeof (this.hasExternalLogger) === "boolean" && this.hasExternalLogger === true){
126+
this.hasExternalLogger = true;
127+
} else {
128+
this.hasExternalLogger = false;
129+
}
130+
131+
if((typeof (this.externalLogger) === "object" && !(this.externalLogger instanceof ExternalLoggerWrapper))
132+
|| this.externalLogger === undefined || !(this.externalLogger.isLoggerEmpty())){
133+
ApiException.LoggerException("No valid external logger object found. Turning off external logger flag.")
134+
this.hasExternalLogger = false;
135+
}
136+
102137
if (typeof (this.enableLog) === "boolean" && this.enableLog === true) {
103138
this.enableLog = true;
104139
} else {

src/authentication/logging/Logger.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const { format } = require('winston');
33
const DataMasker = require('./SensitiveDataMasker');
44
const { combine, timestamp, label, printf } = format;
55
require('winston-daily-rotate-file');
6+
const ExternalLoggerWrapper = require('../logging/ExternalLoggerWrapper');
67

78
const maskedLoggingFormat = printf(({ level, message, label, timestamp }) => {
89
return `[${timestamp}] [${level.toUpperCase()}] [${label}] : ${DataMasker.maskSensitiveData(message)}`;
@@ -13,32 +14,42 @@ const unmaskedLoggingFormat = printf(({ level, message, label, timestamp }) => {
1314
});
1415

1516
exports.getLogger = function (merchantConfig, loggerCategory = 'UnknownCategoryLogger') {
17+
18+
if(merchantConfig.getLogConfiguration().isExternalLoggerSet() && merchantConfig.getLogConfiguration().getExternalLogger()
19+
&& merchantConfig.getLogConfiguration().getExternalLogger().getLogger()
20+
&& merchantConfig.getLogConfiguration().getExternalLogger() instanceof ExternalLoggerWrapper){
21+
let logger = merchantConfig.getLogConfiguration().getExternalLogger().getLogger();
22+
return logger;
23+
}
1624
var enableLog = merchantConfig.getLogConfiguration().isLogEnabled();
1725
var enableMasking = merchantConfig.getLogConfiguration().isMaskingEnabled();
18-
var loggerCategoryRandomiser = Math.floor((Math.random() * 1000) + 1);
26+
var loggerCategoryRandomiser = Math.floor(Math.random() * (1000000000 - 100 + 1)) + 100;
27+
28+
loggerCategory = loggerCategory + loggerCategoryRandomiser;
29+
1930
var newLogger;
2031

2132
if (enableLog) {
2233
var appTransports = createTransportFromConfig(merchantConfig);
2334

2435
var loggingLevel = merchantConfig.getLogConfiguration().getLoggingLevel();
2536

26-
newLogger = winston.loggers.get(loggerCategory + loggerCategoryRandomiser, {
37+
newLogger = winston.loggers.get(loggerCategory, {
2738
level: loggingLevel,
2839
format: combine(
29-
label({ label: loggerCategory }),
30-
timestamp(),
31-
enableMasking ? maskedLoggingFormat : unmaskedLoggingFormat
40+
label({ label: loggerCategory }),
41+
timestamp(),
42+
enableMasking ? maskedLoggingFormat : unmaskedLoggingFormat
3243
),
3344
transports: appTransports
3445
});
3546
} else {
36-
newLogger = winston.loggers.get(loggerCategory + loggerCategoryRandomiser, {
47+
newLogger = winston.loggers.get(loggerCategory, {
3748
level: loggingLevel,
3849
format: combine(
39-
label({ label: loggerCategory }),
40-
timestamp(),
41-
enableMasking ? maskedLoggingFormat : unmaskedLoggingFormat
50+
label({ label: loggerCategory }),
51+
timestamp(),
52+
enableMasking ? maskedLoggingFormat : unmaskedLoggingFormat
4253
),
4354
transports: [new winston.transports.Console({
4455
silent: !enableLog

0 commit comments

Comments
 (0)