New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

auth-net-types

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth-net-types - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

715

lib/index.js

@@ -0,2 +1,55 @@

var xml = require('xml');
/**
Base class for classes that will generate XML for one entity node. Subclasses
should override the `toXmlObj` method.
*/
var XmlEntityGenerator = function() { };
XmlEntityGenerator.prototype.toXmlObj = function() {
console.error('Not implemented');
};
XmlEntityGenerator.prototype.toXml = function() {
var xmlObj = this.toXmlObj();
if (!xmlObj) {
return '';
}
return xml(xmlObj);
};
/**
Base class for classes that will generate XML for a list of entity nodes. Subclasses
should override the `toXmlObjList` method.
*/
var XmlEntityListGenerator = function() { };
XmlEntityListGenerator.prototype.toXmlObjList = function() {
console.error('Not implemented');
};
XmlEntityListGenerator.prototype.toXml = function() {
var xmlObjList = this.toXmlObjList();
if (xmlObjList.length <= 0) {
return '';
}
return xml(xmlObjList);
};
var addXmlObjToList = function(list, key, value) {
if (value) {
var obj = {};
obj[key] = value;
list.push(obj);
}
};
/**
A class that contains all fields for a CIM Customer Profile.

@@ -91,19 +144,20 @@

this.paymentProfiles = new AuthorizePaymentProfiles(options.paymentProfiles);
};
/*
@returns {String} XML output for AuthorizePaymentProfileSimple.
*/
this.toXml = function() {
var xml = '' +
'<profile>' +
(!!this.merchantCustomerId ? '<merchantCustomerId>' + this.merchantCustomerId + '</merchantCustomerId>' : '') +
(!!this.description ? '<description>' + this.description + '</description>' : '') +
(!!this.email ? '<email>' + this.email + '</email>' : '') +
this.paymentProfiles.toXml() +
(this.shipToList.length > 0 ? '<shipToList>' + this.shipToList.toXml() + '</shipToList>' : '') +
'</profile>';
AuthorizeCustomer.prototype = new XmlEntityGenerator();
return xml;
AuthorizeCustomer.prototype.toXmlObj = function() {
var xmlObj = { profile: [] };
addXmlObjToList(xmlObj.profile, 'merchantCustomerId', this.merchantCustomerId);
addXmlObjToList(xmlObj.profile, 'description', this.description);
addXmlObjToList(xmlObj.profile, 'email', this.email);
xmlObj.profile = xmlObj.profile.concat(this.paymentProfiles.toXmlObjList());
if (this.shipToList.length > 0) {
xmlObj.profile.push({ shipToList: this.shipToList.toXmlObjList() });
}
}
return xmlObj;
};
module.exports.Customer = AuthorizeCustomer;

@@ -144,18 +198,17 @@

this.customerProfileId = options.customerProfileId || '';
};
/*
@returns {String} XML output for AuthorizePaymentProfileSimple.
*/
this.toXml = function() {
var xml = '' +
'<profile>' +
(!!this.merchantCustomerId ? '<merchantCustomerId>' + this.merchantCustomerId + '</merchantCustomerId>' : '') +
(!!this.description ? '<description>' + this.description + '</description>' : '') +
(!!this.email ? '<email>' + this.email + '</email>' : '') +
(!!this.customerProfileId ? '<customerProfileId>' + this.customerProfileId + '</customerProfileId>' : '') +
'</profile>';
AuthorizeCustomerBasic.prototype = new XmlEntityGenerator();
return xml;
}
}
AuthorizeCustomerBasic.prototype.toXmlObj = function() {
var xmlObj = { profile: [] };
addXmlObjToList(xmlObj.profile, 'merchantCustomerId', this.merchantCustomerId);
addXmlObjToList(xmlObj.profile, 'description', this.description);
addXmlObjToList(xmlObj.profile, 'email', this.email);
addXmlObjToList(xmlObj.profile, 'customerProfileId', this.customerProfileId);
return xmlObj;
};
module.exports.CustomerBasic = AuthorizeCustomerBasic;

@@ -213,17 +266,16 @@

this.length = this.bin.length;
/*
@returns {String} XML output for AuthorizePaymentProfileSimple.
*/
this.toXml = function() {
if (this.bin.length < 1) {
return '';
}
};
var xml = '';
for (var i = 0; i < this.bin.length; ++i) {
xml += '<billTo>' + this.bin[i].toXml() + '</billTo>';
}
return xml;
AuthorizeBillingAddress.prototype = new XmlEntityListGenerator();
AuthorizeBillingAddress.prototype.toXmlObjList = function() {
var list = [];
for (var i = 0; i < this.bin.length; ++i) {
list.push({ billTo: this.bin[i].toXmlObjList() });
}
}
return list;
};
module.exports.BillingAddress = AuthorizeBillingAddress;

@@ -281,17 +333,24 @@

this.length = this.bin.length;
/*
@returns {String} XML output for AuthorizePaymentProfileSimple.
*/
this.toXml = function() {
if (this.bin.length < 1) {
return '';
}
};
var xml = '';
for (var i = 0; i < this.bin.length; ++i) {
xml += this.bin[i].toXml();
}
return xml;
AuthorizeShippingAddress.prototype = new XmlEntityListGenerator();
AuthorizeShippingAddress.prototype.toXmlObj = function() {
var list = this.toXmlObjList();
if (list.length <= 0) {
return;
}
}
return { shipTo: list };
};
AuthorizeShippingAddress.prototype.toXmlObjList = function() {
var list = [];
for (var i = 0; i < this.bin.length; ++i) {
list = list.concat(this.bin[i].toXmlObjList());
}
return list;
};
module.exports.ShippingAddress = AuthorizeShippingAddress;

@@ -351,23 +410,24 @@

this.customerAddressId = address.customerAddressId || '';
};
/*
@returns {String} XML output for AuthorizePaymentProfileSimple.
*/
this.toXml = function() {
var xml = '' +
(!!this.firstName ? '<firstName>' + this.firstName + '</firstName>' : '') +
(!!this.lastName ? '<lastName>' + this.lastName + '</lastName>' : '') +
(!!this.company ? '<company>' + this.company + '</company>' : '') +
(!!this.address ? '<address>' + this.address + '</address>' : '') +
(!!this.city ? '<city>' + this.city + '</city>' : '') +
(!!this.state ? '<state>' + this.state + '</state>' : '') +
(!!this.zip ? '<zip>' + this.zip + '</zip>' : '') +
(!!this.country ? '<country>' + this.country + '</country>' : '') +
(!!this.phoneNumber ? '<phoneNumber>' + this.phoneNumber + '</phoneNumber>' : '') +
(!!this.faxNumber ? '<faxNumber>' + this.faxNumber + '</faxNumber>' : '') +
(!!this.customerAddressId ? '<customerAddressId>' + this.customerAddressId + '</customerAddressId>' : '');
AuthorizeAddress.prototype = new XmlEntityListGenerator();
return xml;
}
}
AuthorizeAddress.prototype.toXmlObjList = function() {
var xmlObjList = [];
addXmlObjToList(xmlObjList, 'firstName', this.firstName);
addXmlObjToList(xmlObjList, 'lastName', this.lastName);
addXmlObjToList(xmlObjList, 'company', this.company);
addXmlObjToList(xmlObjList, 'address', this.address);
addXmlObjToList(xmlObjList, 'city', this.city);
addXmlObjToList(xmlObjList, 'state', this.state);
addXmlObjToList(xmlObjList, 'zip', this.zip);
addXmlObjToList(xmlObjList, 'country', this.country);
addXmlObjToList(xmlObjList, 'phoneNumber', this.phoneNumber);
addXmlObjToList(xmlObjList, 'faxNumber', this.faxNumber);
addXmlObjToList(xmlObjList, 'customerAddressId', this.customerAddressId);
return xmlObjList;
};
module.exports.Address = AuthorizeAddress;

@@ -459,23 +519,23 @@

this.length = this.bin.length;
/*
@returns {String} XML output for AuthorizePaymentProfileSimple.
*/
this.toXml = function() {
if (this.bin.length < 1) {
return '';
}
};
var xml = '';
for (var i = 0; i < this.bin.length; ++i) {
xml += '<paymentProfiles>' +
(!!this.bin[i].customerType ? '<customerType>' + this.bin[i].customerType + '</customerType>' : '') +
(!!this.bin[i].customerPaymentProfileId ? '<customerPaymentProfileId>' + this.bin[i].customerPaymentProfileId + '</customerPaymentProfileId>' : '') +
this.bin[i].billTo.toXml() +
this.bin[i].payment.toXml() +
'</paymentProfiles>';
}
AuthorizePaymentProfiles.prototype = new XmlEntityListGenerator();
return xml;
AuthorizePaymentProfiles.prototype.toXmlObjList = function() {
var list = [];
for (var i = 0; i < this.bin.length; ++i) {
var xmlObj = { paymentProfiles: [] };
addXmlObjToList(xmlObj.paymentProfiles, 'customerType', this.bin[i].customerType);
addXmlObjToList(xmlObj.paymentProfiles, 'customerPaymentProfileId', this.bin[i].customerPaymentProfileId);
xmlObj.paymentProfiles = xmlObj.paymentProfiles.concat(this.bin[i].billTo.toXmlObjList());
xmlObj.paymentProfiles.push(this.bin[i].payment.toXmlObj());
list.push(xmlObj);
}
}
return list;
};
module.exports.PaymentProfiles = AuthorizePaymentProfiles;

@@ -566,23 +626,27 @@

this.length = this.bin.length;
/*
@returns {String} XML output for AuthorizePaymentProfiles.
*/
this.toXml = function() {
if (this.bin.length < 1) {
return '';
}
};
var xml = '';
for (var i = 0; i < this.bin.length; ++i) {
xml += '<paymentProfile>' +
(!!this.bin[i].customerType ? '<customerType>' + this.bin[i].customerType + '</customerType>' : '') +
this.bin[i].billTo.toXml() +
this.bin[i].payment.toXml() +
(!!this.bin[i].customerPaymentProfileId ? '<customerPaymentProfileId>' + this.bin[i].customerPaymentProfileId + '</customerPaymentProfileId>' : '') +
'</paymentProfile>';
}
AuthorizePaymentProfile.prototype = new XmlEntityListGenerator();
return xml;
AuthorizePaymentProfile.prototype.toXmlObjList = function() {
if (this.bin.length < 1) {
return;
}
}
var list = [], xmlObj;
for (var i = 0; i < this.bin.length; ++i) {
xmlObj = { paymentProfile: [] };
addXmlObjToList(xmlObj.paymentProfile, 'customerType', this.bin[i].customerType);
xmlObj.paymentProfile = xmlObj.paymentProfile.concat(this.bin[i].billTo.toXmlObjList());
xmlObj.paymentProfile.push(this.bin[i].payment.toXmlObj());
addXmlObjToList(xmlObj.paymentProfile, 'customerPaymentProfileId', this.bin[i].customerPaymentProfileId);
list.push(xmlObj);
}
return list;
};
module.exports.PaymentProfile = AuthorizePaymentProfile;

@@ -695,24 +759,21 @@

this.length = this.bin.length;
/*
@returns {String} XML output for AuthorizePaymentProfileSimple.
*/
this.toXml = function() {
if (this.bin.length < 1) {
return '';
}
};
var xml = '<payment>';
for (var i = 0; i < this.bin.length; ++i) {
if (this.bin[i].creditCard.length > 0) {
xml += this.bin[i].creditCard.toXml();
}
if (this.bin[i].bankAccount.length > 0) {
xml += this.bin[i].bankAccount.toXml();
}
AuthorizePayment.prototype = new XmlEntityGenerator();
AuthorizePayment.prototype.toXmlObj = function() {
var xmlObj = { payment: [] };
for (var i = 0; i < this.bin.length; ++i) {
if (this.bin[i].creditCard.length > 0) {
xmlObj.payment.push(this.bin[i].creditCard.toXmlObj());
}
xml += '</payment>';
if (this.bin[i].bankAccount.length > 0) {
xmlObj.payment.push(this.bin[i].bankAccount.toXmlObj());
}
}
return xml;
}
}
return xmlObj;
};
module.exports.Payment = AuthorizePayment;

@@ -780,24 +841,21 @@

this.length = this.bin.length;
};
/*
@returns {String} XML output for AuthorizePaymentSimple.
*/
this.toXml = function() {
if (this.bin.length < 1) {
return '';
}
AuthorizePaymentSimple.prototype = new XmlEntityListGenerator();
var xml = '';
for (var i = 0; i < this.bin.length; ++i) {
if (this.bin[i].creditCard.length > 0) {
xml += this.bin[i].creditCard.toXml();
}
if (this.bin[i].bankAccount.length > 0) {
xml += this.bin[i].bankAccount.toXml();
}
AuthorizePaymentSimple.prototype.toXmlObjList = function() {
var list = [];
for (var i = 0; i < this.bin.length; ++i) {
if (this.bin[i].creditCard.length > 0) {
list.push(this.bin[i].creditCard.toXmlObj());
}
if (this.bin[i].bankAccount.length > 0) {
list.push(this.bin[i].bankAccount.toXmlObj());
}
}
return xml;
}
}
return list;
};
module.exports.PaymentSimple = AuthorizePaymentSimple;

@@ -916,30 +974,31 @@

this.approvalCode = options.approvalCode || '';
};
/*
@returns {String} XML output for AuthorizeTransaction.
*/
this.toXml = function() {
var xml = '' +
(!!this.amount ? '<amount>' + this.amount + '</amount>' : '') +
this.tax.toXml() +
this.shipping.toXml() +
this.duty.toXml() +
this.lineItems.toXml() +
(!!this.customerProfileId ? '<customerProfileId>' + this.customerProfileId + '</customerProfileId>' : '') +
(!!this.customerPaymentProfileId ? '<customerPaymentProfileId>' + this.customerPaymentProfileId + '</customerPaymentProfileId>' : '') +
(!!this.customerShippingAddressId ? '<customerShippingAddressId>' + this.customerShippingAddressId + '</customerShippingAddressId>' : '') +
(!!this.creditCardNumberMasked ? '<creditCardNumberMasked>' + this.creditCardNumberMasked + '</creditCardNumberMasked>' : '') +
(!!this.bankRoutingNumberMasked ? '<bankRoutingNumberMasked>' + this.bankRoutingNumberMasked + '</bankRoutingNumberMasked>' : '') +
(!!this.bankAccountNumberMasked ? '<bankAccountNumberMasked>' + this.bankAccountNumberMasked + '</bankAccountNumberMasked>' : '') +
this.order.toXml() +
(!!this.transId ? '<transId>' + this.transId + '</transId>' : '') +
(!!this.taxExempt ? '<taxExempt>' + this.taxExempt + '</taxExempt>' : '') +
(!!this.recurringBilling ? '<recurringBilling>' + this.recurringBilling + '</recurringBilling>' : '') +
(!!this.cardCode ? '<cardCode>' + this.cardCode + '</cardCode>' : '') +
(!!this.splitTenderId ? '<splitTenderId>' + this.splitTenderId + '</splitTenderId>' : '') +
(!!this.approvalCode ? '<approvalCode>' + this.approvalCode + '</approvalCode>' : '');
AuthorizeTransaction.prototype = new XmlEntityListGenerator();
return xml;
}
}
AuthorizeTransaction.prototype.toXmlObjList = function() {
var list = [];
addXmlObjToList(list, 'amount', this.amount);
list.push(this.tax.toXmlObj())
list.push(this.shipping.toXmlObj())
list.push(this.duty.toXmlObj())
list = list.concat(this.lineItems.toXmlObjList())
addXmlObjToList(list, 'customerProfileId', this.customerProfileId);
addXmlObjToList(list, 'customerPaymentProfileId', this.customerPaymentProfileId);
addXmlObjToList(list, 'customerShippingAddressId', this.customerShippingAddressId);
addXmlObjToList(list, 'creditCardNumberMasked', this.creditCardNumberMasked);
addXmlObjToList(list, 'bankRoutingNumberMasked', this.bankRoutingNumberMasked);
addXmlObjToList(list, 'bankAccountNumberMasked', this.bankAccountNumberMasked);
list.push(this.order.toXmlObj())
addXmlObjToList(list, 'transId', this.transId);
addXmlObjToList(list, 'taxExempt', this.taxExempt);
addXmlObjToList(list, 'recurringBilling', this.recurringBilling);
addXmlObjToList(list, 'cardCode', this.cardCode);
addXmlObjToList(list, 'splitTenderId', this.splitTenderId);
addXmlObjToList(list, 'approvalCode', this.approvalCode);
return list;
};
module.exports.Transaction = AuthorizeTransaction;

@@ -978,20 +1037,20 @@

this.length = Object.keys(options).filter(function(o) { return !!options[o]; }).length;
};
/*
@returns {String} XML output for AuthorizeDuty.
*/
this.toXml = function() {
if (this.length < 1) {
return '';
}
AuthorizeDuty.prototype = new XmlEntityGenerator();
var xml = '<duty>' +
(!!this.amount ? '<amount>' + this.amount + '</amount>' : '') +
(!!this.name ? '<name>' + this.name + '</name>' : '') +
(!!this.description ? '<description>' + this.description + '</description>' : '') +
'</duty>';
AuthorizeDuty.prototype.toXmlObj = function() {
if (this.length < 1) {
return;
}
return xml;
}
}
var xmlObj = { duty: [] };
addXmlObjToList(xmlObj.duty, 'amount', this.amount);
addXmlObjToList(xmlObj.duty, 'name', this.name);
addXmlObjToList(xmlObj.duty, 'description', this.description);
return xmlObj;
};
module.exports.Duty = AuthorizeDuty;

@@ -1030,20 +1089,20 @@

this.length = Object.keys(options).filter(function(o) { return !!options[o]; }).length;
};
/*
@returns {String} XML output for AuthorizeOrder.
*/
this.toXml = function() {
if (this.length < 1) {
return '';
}
AuthorizeOrder.prototype = new XmlEntityGenerator();
var xml = '<order>' +
(!!this.invoiceNumber ? '<invoiceNumber>' + this.invoiceNumber + '</invoiceNumber>' : '') +
(!!this.description ? '<description>' + this.description + '</description>' : '') +
(!!this.purchaseOrderNumber ? '<purchaseOrderNumber>' + this.purchaseOrderNumber + '</purchaseOrderNumber>' : '') +
'</order>';
AuthorizeOrder.prototype.toXmlObj = function() {
if (this.length < 1) {
return;
}
return xml;
}
}
var xmlObj = { order: [] };
addXmlObjToList(xmlObj.order, 'invoiceNumber', this.invoiceNumber);
addXmlObjToList(xmlObj.order, 'description', this.description);
addXmlObjToList(xmlObj.order, 'purchaseOrderNumber', this.purchaseOrderNumber);
return xmlObj;
};
module.exports.Order = AuthorizeOrder;

@@ -1082,20 +1141,20 @@

this.length = Object.keys(options).filter(function(o) { return !!options[o]; }).length;
};
/*
@returns {String} XML output for AuthorizeShipping.
*/
this.toXml = function() {
if (this.length < 1) {
return '';
}
AuthorizeShipping.prototype = new XmlEntityGenerator();
var xml = '<shipping>' +
(!!this.amount ? '<amount>' + this.amount + '</amount>' : '') +
(!!this.name ? '<name>' + this.name + '</name>' : '') +
(!!this.description ? '<description>' + this.description + '</description>' : '') +
'</shipping>';
AuthorizeShipping.prototype.toXmlObj = function() {
if (this.length < 1) {
return;
}
return xml;
}
}
var xmlObj = { shipping: [] };
addXmlObjToList(xmlObj.shipping, 'amount', this.amount);
addXmlObjToList(xmlObj.shipping, 'name', this.name);
addXmlObjToList(xmlObj.shipping, 'description', this.description);
return xmlObj;
};
module.exports.Shipping = AuthorizeShipping;

@@ -1135,20 +1194,20 @@

this.length = Object.keys(options).filter(function(o) { return !!options[o]; }).length;
};
/*
@returns {String} XML output for AuthorizeTax.
*/
this.toXml = function() {
if (this.length < 1) {
return '';
}
AuthorizeTax.prototype = new XmlEntityGenerator();
var xml = '<tax>' +
(!!this.amount ? '<amount>' + this.amount + '</amount>' : '') +
(!!this.name ? '<name>' + this.name + '</name>' : '') +
(!!this.description ? '<description>' + this.description + '</description>' : '') +
'</tax>';
AuthorizeTax.prototype.toXmlObj = function() {
if (this.length < 1) {
return;
}
return xml;
}
}
var xmlObj = { tax: [] };
addXmlObjToList(xmlObj.tax, 'amount', this.amount);
addXmlObjToList(xmlObj.tax, 'name', this.name);
addXmlObjToList(xmlObj.tax, 'description', this.description);
return xmlObj;
};
module.exports.Tax = AuthorizeTax;

@@ -1196,26 +1255,27 @@

this.length = this.bin.length;
};
/*
@returns {String} XML output for AuthorizeLineItems.
*/
this.toXml = function() {
if (this.length < 1) {
return '';
}
AuthorizeLineItems.prototype = new XmlEntityListGenerator();
var xml = '';
for (var i = 0; i < this.bin.length; ++i) {
xml += '<lineItems>' +
(!!this.bin[i].itemId ? '<itemId>' + this.bin[i].itemId + '</itemId>' : '') +
(!!this.bin[i].name ? '<name>' + this.bin[i].name + '</name>' : '') +
(!!this.bin[i].description ? '<description>' + this.bin[i].description + '</description>' : '') +
(!!this.bin[i].quantity ? '<quantity>' + this.bin[i].quantity + '</quantity>' : '') +
(!!this.bin[i].unitPrice ? '<unitPrice>' + this.bin[i].unitPrice + '</unitPrice>' : '') +
(this.bin[i].hasOwnProperty('taxable') ? '<taxable>' + this.bin[i].taxable.toString() + '</taxable>' : '') +
'</lineItems>';
AuthorizeLineItems.prototype.toXmlObjList = function() {
var list = [];
for (var i = 0; i < this.bin.length; ++i) {
var xmlObj = { lineItems: [] };
addXmlObjToList(xmlObj.lineItems, 'itemId', this.bin[i].itemId);
addXmlObjToList(xmlObj.lineItems, 'name', this.bin[i].name);
addXmlObjToList(xmlObj.lineItems, 'description', this.bin[i].description);
addXmlObjToList(xmlObj.lineItems, 'quantity', this.bin[i].quantity);
addXmlObjToList(xmlObj.lineItems, 'unitPrice', this.bin[i].unitPrice);
if (this.bin[i].hasOwnProperty('taxable')) {
addXmlObjToList(xmlObj.lineItems, 'taxable', this.bin[i].taxable.toString());
}
return xml;
list.push(xmlObj);
}
}
return list;
};
module.exports.LineItems = AuthorizeLineItems;

@@ -1252,20 +1312,20 @@

this.length = !this.cardNumber ? 0 : 1;
};
/*
@returns {String} XML output for AuthorizeLineItems.
*/
this.toXml = function() {
if (!this.cardNumber) {
return '';
}
AuthorizeCreditCard.prototype = new XmlEntityGenerator();
var xml = '<creditCard>' +
(!!this.cardNumber ? '<cardNumber>' + this.cardNumber + '</cardNumber>' : '') +
(!!this.expirationDate ? '<expirationDate>' + this.expirationDate + '</expirationDate>' : '') +
(!!this.cardCode ? '<cardCode>' + this.cardCode + '</cardCode>' : '') +
'</creditCard>';
AuthorizeCreditCard.prototype.toXmlObj = function() {
if (!this.cardNumber) {
return;
}
return xml;
}
}
var xmlObj = { creditCard: [] };
addXmlObjToList(xmlObj.creditCard, 'cardNumber', this.cardNumber);
addXmlObjToList(xmlObj.creditCard, 'expirationDate', this.expirationDate);
addXmlObjToList(xmlObj.creditCard, 'cardCode', this.cardCode);
return xmlObj;
};
module.exports.CreditCard = AuthorizeCreditCard;

@@ -1311,22 +1371,22 @@

this.length = !this.accountType ? 0 : 1;
};
/*
@returns {String} XML output for AuthorizeLineItems.
*/
this.toXml = function() {
if (!this.accountNumber) {
return '';
}
AuthorizeBankAccount.prototype = new XmlEntityGenerator();
var xml = '<bankAccount>' +
(!!this.accountType ? '<accountType>' + this.accountType + '</accountType>' : '') +
(!!this.routingNumber ? '<routingNumber>' + this.routingNumber + '</routingNumber>' : '') +
(!!this.accountNumber ? '<accountNumber>' + this.accountNumber + '</accountNumber>' : '') +
(!!this.echeckType ? '<echeckType>' + this.echeckType + '</echeckType>' : '') +
(!!this.nameOnAccount ? '<nameOnAccount>' + this.nameOnAccount + '</nameOnAccount>' : '') +
'</bankAccount>';
AuthorizeBankAccount.prototype.toXmlObj = function() {
if (!this.accountNumber) {
return '';
}
return xml;
}
}
var xmlObj = { bankAccount: [] };
addXmlObjToList(xmlObj.bankAccount, 'accountType', this.accountType);
addXmlObjToList(xmlObj.bankAccount, 'routingNumber', this.routingNumber);
addXmlObjToList(xmlObj.bankAccount, 'accountNumber', this.accountNumber);
addXmlObjToList(xmlObj.bankAccount, 'echeckType', this.echeckType);
addXmlObjToList(xmlObj.bankAccount, 'nameOnAccount', this.nameOnAccount);
return xmlObj;
};
module.exports.BankAccount = AuthorizeBankAccount;

@@ -1376,23 +1436,22 @@

this.length = (!!options.interval.length ? 1 : 0);
/*
@returns {String} XML output for AuthorizeLineItems.
*/
this.toXml = function() {
if (this.length < 1) {
return '';
}
};
var xml = '<paymentSchedule>' +
'<interval>' +
(!!this.interval.length ? '<length>' + this.interval.length + '</length>' : '') +
(!!this.interval.unit ? '<unit>' + this.interval.unit + '</unit>' : '') +
'</interval>' +
(!!this.startDate ? '<startDate>' + this.startDate + '</startDate>' : '') +
(!!this.totalOccurences ? '<totalOccurences>' + this.totalOccurences + '</totalOccurences>' : '') +
(!!this.trialOccurences ? '<trialOccurences>' + this.trialOccurences + '</trialOccurences>' : '') +
'</paymentSchedule>';
AuthorizePaymentSchedule.prototype = new XmlEntityGenerator();
return xml;
AuthorizePaymentSchedule.prototype.toXmlObj = function() {
if (this.length < 1) {
return;
}
}
var xmlObj = { paymentSchedule: [ { interval: [] } ] };
addXmlObjToList(xmlObj.paymentSchedule[0].interval, 'length', this.interval.length);
addXmlObjToList(xmlObj.paymentSchedule[0].interval, 'unit', this.interval.unit);
addXmlObjToList(xmlObj.paymentSchedule, 'startDate', this.startDate);
addXmlObjToList(xmlObj.paymentSchedule, 'totalOccurences', this.totalOccurences);
addXmlObjToList(xmlObj.paymentSchedule, 'trialOccurences', this.trialOccurences);
return xmlObj;
};
module.exports.PaymentSchedule = AuthorizePaymentSchedule;

@@ -1535,31 +1594,37 @@

this.shipTo = new AuthorizeShippingAddress(options.shipTo);
};
/*
@returns {String} XML output for AuthorizeLineItems.
*/
this.toXml = function() {
var xml = '<subscription>' +
'<name>' + this.name + '</name>' +
this.paymentSchedule.toXml() +
(!!this.amount ? '<amount>' + this.amount + '</amount>' : '') +
(!!this.trialAmount ? '<trialAmount>' + this.trialAmount + '</trialAmount>' : '') +
this.payment.toXml() +
this.order.toXml();
AuthorizeSubscription.prototype = new XmlEntityGenerator();
if (!!this.customer.id || !!this.customer.email || !!this.customer.phoneNumber || !!this.customer.faxNumber) {
xml += '<customer>' +
(!!this.customer.id ? '<id>' + this.customer.id + '</id>' : '') +
(!!this.customer.email ? '<email>' + this.customer.email + '</email>' : '') +
(!!this.customer.phoneNumber ? '<phoneNumber>' + this.customer.phoneNumber + '</phoneNumber>' : '') +
(!!this.customer.faxNumber ? '<faxNumber>' + this.customer.faxNumber + '</faxNumber>' : '') +
'</customer>';
}
AuthorizeSubscription.prototype.toXmlObj = function() {
var xmlObj = { subscription: [] };
xml += this.billTo.toXml() +
(this.shipTo.length > 0 ? '<shipTo>' + this.shipTo.toXml() + '</shipTo>' : '') +
'</subscription>';
addXmlObjToList(xmlObj.subscription, 'name', this.name);
xmlObj.subscription.push(this.paymentSchedule.toXmlObj());
addXmlObjToList(xmlObj.subscription, 'amount', this.amount);
addXmlObjToList(xmlObj.subscription, 'trialAmount', this.trialAmount);
xmlObj.subscription.push(this.payment.toXmlObj());
xmlObj.subscription.push(this.order.toXmlObj());
return xml;
if (!!this.customer.id || !!this.customer.email || !!this.customer.phoneNumber || !!this.customer.faxNumber) {
var customerXmlObj = { customer: [] };
addXmlObjToList(customerXmlObj.customer, 'id', this.customer.id);
addXmlObjToList(customerXmlObj.customer, 'email', this.customer.email);
addXmlObjToList(customerXmlObj.customer, 'phoneNumber', this.customer.phoneNumber);
addXmlObjToList(customerXmlObj.customer, 'faxNumber', this.customer.faxNumber);
xmlObj.subscription.push(customerXmlObj);
}
}
xmlObj.subscription = xmlObj.subscription.concat(this.billTo.toXmlObjList());
var shipTo = this.shipTo.toXmlObj();
if (shipTo) {
xmlObj.subscription.push(shipTo);
}
return xmlObj;
};
module.exports.Subscription = AuthorizeSubscription;
{
"name": "auth-net-types",
"version": "1.0.3",
"version": "1.1.0",
"description": "A collection of Authorize.net's types/data types/xml objects.",

@@ -24,5 +24,8 @@ "main": "index.js",

"devDependencies": {
"mocha": "^1.18.2",
"chai": "~1.9.0"
"mocha": "^2.0.1",
"chai": "^1.10.0"
},
"dependencies": {
"xml": ">=0.0.8"
}
}

@@ -10,3 +10,3 @@ var Types = require(__dirname + '/../index')

merchantCustomerId: 123,
description: 'A customer with a lot of cash.',
description: 'A customer with a lot of cash & stuff.',
email: 'completelyfake@dontemail.com',

@@ -18,5 +18,5 @@ customerProfileId: 1234

expect(Customer.merchantCustomerId).to.equal(123);
expect(Customer.description).to.equal('A customer with a lot of cash.');
expect(Customer.description).to.equal('A customer with a lot of cash & stuff.');
expect(Customer.customerProfileId).to.equal(1234);
expect(Customer.toXml()).to.equal('<profile><merchantCustomerId>123</merchantCustomerId><description>A customer with a lot of cash.</description><email>completelyfake@dontemail.com</email></profile>');
expect(Customer.toXml()).to.equal('<profile><merchantCustomerId>123</merchantCustomerId><description>A customer with a lot of cash &amp; stuff.</description><email>completelyfake@dontemail.com</email></profile>');

@@ -80,3 +80,3 @@ // Let's create a paymentProfile

expect(Customer.toXml()).to.equal('<profile><merchantCustomerId>123</merchantCustomerId><description>A customer with a lot of cash.</description><email>completelyfake@dontemail.com</email><paymentProfiles><customerType>individual</customerType><customerPaymentProfileId>12345</customerPaymentProfileId><billTo><firstName>Bob</firstName><lastName>Smith</lastName><address>123 Sesame St</address><city>Johnesville</city><state>FL</state><zip>123</zip><country>US</country><phoneNumber>555-123-1234</phoneNumber><faxNumber>555-123-1235</faxNumber></billTo><payment><creditCard><cardNumber>41111111111111111</cardNumber><expirationDate>10-12</expirationDate><cardCode>123</cardCode></creditCard></payment></paymentProfiles></profile>');
expect(Customer.toXml()).to.equal('<profile><merchantCustomerId>123</merchantCustomerId><description>A customer with a lot of cash &amp; stuff.</description><email>completelyfake@dontemail.com</email><paymentProfiles><customerType>individual</customerType><customerPaymentProfileId>12345</customerPaymentProfileId><billTo><firstName>Bob</firstName><lastName>Smith</lastName><address>123 Sesame St</address><city>Johnesville</city><state>FL</state><zip>123</zip><country>US</country><phoneNumber>555-123-1234</phoneNumber><faxNumber>555-123-1235</faxNumber></billTo><payment><creditCard><cardNumber>41111111111111111</cardNumber><expirationDate>10-12</expirationDate><cardCode>123</cardCode></creditCard></payment></paymentProfiles></profile>');

@@ -83,0 +83,0 @@ done();

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc