I am trying to pass customerId, customerDescription, and customerEmail into createCustomerProfile. The callback variable was default by the original author, and I am trying to extend the module to take these extra variables.
Can I pass them in somehow? I tried using the bind function, but it kept throwing errors, and I'm not sure how to proceed. I had a similar problem and I could use object literal syntax to pass in JSON-like data, but the callback variable is throwing me off.
index.js
const profiles = require('./authorize-net/lib/init-profile.js');
profiles.createCustomerProfile(function() {
console.log('call back');
});
init-profile.js
// require some stuff...
function createCustomerProfile(callback, customerId, customerDescription, customerEmail) {
let cardNumber = '4242424242424242';
let cardExp = '0822';
// set some properties...
let customerProfileType = new ApiContracts.CustomerProfileType();
customerProfileType.setMerchantCustomerId(customerId);
customerProfileType.setDescription(customerDescription);
customerProfileType.setEmail(customerEmail);
customerProfileType.setPaymentProfiles(paymentProfilesList);
let ctrl = new ApiControllers.CreateCustomerProfileController(createRequest.getJSON());
ctrl.execute(function(){
let apiResponse = ctrl.getResponse();
let response = new ApiContracts.CreateCustomerProfileResponse(apiResponse);
callback(response);
});
}
if (require.main === module) {
createCustomerProfile(function(){
console.log('createCustomerProfile call complete.');
});
}
module.exports.createCustomerProfile = createCustomerProfile;
via KVNA
No comments:
Post a Comment