Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions Data/ConfigurationForBatchUpload.js
Original file line number Diff line number Diff line change
@@ -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;
Binary file added Resource/qaebc2.p12
Binary file not shown.
5 changes: 5 additions & 0 deletions Resource/qaebc2.rgdltnd0.csv
Original file line number Diff line number Diff line change
@@ -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
48 changes: 48 additions & 0 deletions Samples/TransactionBatches/upload-transaction-batch.js
Original file line number Diff line number Diff line change
@@ -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;