Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create get-account-updater-job-details.js #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
93 changes: 93 additions & 0 deletions TransactionReporting/get-account-updater-job-details.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
'use strict';

var ApiContracts = require('authorizenet').APIContracts;
var ApiControllers = require('authorizenet').APIControllers;
var utils = require('../utils.js');
var constants = require('../constants.js');

function GetAUJobDetails(callback) {

var merchantAuthenticationType = new ApiContracts.MerchantAuthenticationType();
merchantAuthenticationType.setName(constants.apiLoginKey);
merchantAuthenticationType.setTransactionKey(constants.transactionKey);

var creditCard = new ApiContracts.CreditCardType();
creditCard.setCardNumber('4242424242424242');
creditCard.setExpirationDate('0822');

var paymentType = new ApiContracts.PaymentType();
paymentType.setCreditCard(creditCard);

var customerAddress = new ApiContracts.CustomerAddressType();
customerAddress.setFirstName('test');
customerAddress.setLastName('scenario');
customerAddress.setAddress('123 Main Street');
customerAddress.setCity('Bellevue');
customerAddress.setState('WA');
customerAddress.setZip('98004');
customerAddress.setCountry('USA');
customerAddress.setPhoneNumber('000-000-0000');

//var customerPaymentProfileType = new ApiContracts.CustomerPaymentProfileType();
//customerPaymentProfileType.setCustomerType(ApiContracts.CustomerTypeEnum.INDIVIDUAL);
//customerPaymentProfileType.setPayment(paymentType);
//customerPaymentProfileType.setBillTo(customerAddress);

//var paymentProfilesList = [];
//paymentProfilesList.push(customerPaymentProfileType);

/*var customerProfileType = new ApiContracts.CustomerProfileType();
customerProfileType.setMerchantCustomerId('M_' + utils.getRandomString('cust'));
customerProfileType.setDescription('Profile description here');
customerProfileType.setEmail(utils.getRandomString('cust')+'@anet.net');
customerProfileType.setPaymentProfiles(paymentProfilesList);*/

var createRequest = new ApiContracts.GetAUJobDetailsRequest();
//createRequest.setProfile(customerProfileType);
//createRequest.setValidationMode(ApiContracts.ValidationModeEnum.TESTMODE);
createRequest.setMerchantAuthentication(merchantAuthenticationType);

//pretty print request
//console.log(JSON.stringify(createRequest.getJSON(), null, 2));


var ctrl = new ApiControllers.GetAUJobDetailsController(createRequest.getJSON());

ctrl.execute(function(){

var apiResponse = ctrl.getResponse();

var response = new ApiContracts.GetAUJobDetailsResponse(apiResponse);

//pretty print response
//console.log(JSON.stringify(response, null, 2));

if(response != null)
{
if(response.getMessages().getResultCode() == ApiContracts.MessageTypeEnum.OK)
{
console.log('Successfully created ' + response.GetAUJobDetails());
}
else
{
console.log('Result Code: ' + response.getMessages().getResultCode());
console.log('Error Code: ' + response.getMessages().getMessage()[0].getCode());
console.log('Error message: ' + response.getMessages().getMessage()[0].getText());
}
}
else
{
console.log('Null response received');
}

callback(response);
});
}

if (require.main === module) {
GetAUJobDetails(function(){
console.log('GetAUJobDetails call complete.');
});
}

module.exports.GetAUJobDetails = GetAUJobDetails;