diff --git a/Data/ConfigurationForBatchUpload.js b/Data/ConfigurationForBatchUpload.js new file mode 100644 index 0000000..b1cf7e1 --- /dev/null +++ b/Data/ConfigurationForBatchUpload.js @@ -0,0 +1,75 @@ +'use strict'; + +/* +* Merchant configuration properties are taken from Configuration module +*/ + +// common parameters +const AuthenticationType = 'jwt'; +const RunEnvironment = 'apitest.cybersource.com'; +const MerchantId = 'qaebc2'; + +// http_signature parameters +const MerchantKeyId = ''; +const MerchantSecretKey = ''; + +// jwt parameters +const KeysDirectory = 'Resource'; +const KeyFileName = 'qaebc2'; +const KeyAlias = 'qaebc2'; +const KeyPass = '?Test1234'; + +//meta key parameters +const UseMetaKey = false; +const PortfolioID = ''; + +// logging parameters +const EnableLog = true; +const LogFileName = 'cybs'; +const LogDirectory = 'log'; +const LogfileMaxSize = '5242880'; //10 MB In Bytes +const EnableMasking = true; + +/* +PEM Key file path for decoding JWE Response Enter the folder path where the .pem file is located. +It is optional property, require adding only during JWE decryption. +*/ +const PemFileDirectory = 'Resource/NetworkTokenCert.pem'; + +//Add the property if required to override the cybs default developerId in all request body +const DefaultDeveloperId = ''; + +// Constructor for Configuration +function Configuration() { + + var configObj = { + 'authenticationType': AuthenticationType, + 'runEnvironment': RunEnvironment, + + 'merchantID': MerchantId, + 'merchantKeyId': MerchantKeyId, + 'merchantsecretKey': MerchantSecretKey, + + 'keyAlias': KeyAlias, + 'keyPass': KeyPass, + 'keyFileName': KeyFileName, + 'keysDirectory': KeysDirectory, + + 'useMetaKey': UseMetaKey, + 'portfolioID': PortfolioID, + 'pemFileDirectory': PemFileDirectory, + 'defaultDeveloperId': DefaultDeveloperId, + 'logConfiguration': { + 'enableLog': EnableLog, + 'logFileName': LogFileName, + 'logDirectory': LogDirectory, + 'logFileMaxSize': LogfileMaxSize, + 'loggingLevel': 'debug', + 'enableMasking': EnableMasking + } + }; + return configObj; + +} + +module.exports = Configuration; diff --git a/Resource/qaebc2.p12 b/Resource/qaebc2.p12 new file mode 100644 index 0000000..a66a4e2 Binary files /dev/null and b/Resource/qaebc2.p12 differ diff --git a/Resource/qaebc2.rgdltnd0.csv b/Resource/qaebc2.rgdltnd0.csv new file mode 100644 index 0000000..0b8df03 --- /dev/null +++ b/Resource/qaebc2.rgdltnd0.csv @@ -0,0 +1,5 @@ +merchantID=qaebc2,batchID=rgdltnd0,recordCount=2,statusEmail=ynachire@visa.com,targetAPIVersion=1.86,creationDate=2025-03-05,reference= +merchantID,merchantReferenceCode,merchantDefinedData_field1,ccAuthService_run,billTo_firstName,billTo_lastName,billTo_email,billTo_street1,billTo_city,billTo_state,billTo_country,billTo_postalCode,card_accountNumber,card_expirationMonth,card_expirationYear,card_cardType,purchaseTotals_currency,purchaseTotals_grandTotalAmount,item_#_productCode +qaebc2,1,4837,true,Jay,Smith,ynachire@visa.com,8 Mission Street,San Francisco,CA,US,94101,4111111111111111,12,2036,001,GBP,8.00,1 +qaebc2,2,7209,true,Jay,Smith,ynachire@visa.com,8 Mission Street,San Francisco,CA,US,94101,4111111111111111,12,2036,001,GBP,8.00,1 +END,SUM=16.00 \ No newline at end of file diff --git a/Samples/TransactionBatches/upload-transaction-batch.js b/Samples/TransactionBatches/upload-transaction-batch.js new file mode 100644 index 0000000..59e0ad8 --- /dev/null +++ b/Samples/TransactionBatches/upload-transaction-batch.js @@ -0,0 +1,48 @@ +'use strict'; + +var cybersourceRestApi = require('cybersource-rest-client'); +var path = require('path'); +var filePath = path.resolve('Data/ConfigurationForBatchUpload.js'); +var configuration = require(filePath); + +function upload_transaction_batch(callback) { + try { + var configObject = new configuration(); + var apiClient = new cybersourceRestApi.ApiClient(); + var fileToUpload = 'Resource/qaebc2.rgdltnd0.csv'; + + var opts = []; + + var instance = new cybersourceRestApi.TransactionBatchesApi(configObject, apiClient); + + instance.uploadTransactionBatch(fileToUpload, function (error, data, response) { + if (error) { + console.log('\nError : ' + JSON.stringify(error)); + } + else if (data) { + console.log('\nData : ' + JSON.stringify(data)); + } + + console.log('\nResponse : ' + JSON.stringify(response)); + console.log('\nResponse Code of Upload Transaction Batch : ' + JSON.stringify(response['status'])); + var status = response['status']; + write_log_audit(status); + callback(error, data, response); + }); + } + catch (error) { + console.log('\nException on calling the API : ' + error); + } +} + +function write_log_audit(status) { + var filename = path.basename(__filename).split(".")[0]; + console.log(`[Sample Code Testing] [${filename}] ${status}`); +} + +if (require.main === module) { + upload_transaction_batch(function () { + console.log('\nUploadTransactionBatch end.'); + }); +} +module.exports.upload_transaction_batch = upload_transaction_batch;