public override string Serialize()
{
string xml = "\r\n<sale";
xml += " id=\"" + SecurityElement.Escape(id) + "\"";
if (customerId != null)
{
xml += " customerId=\"" + SecurityElement.Escape(customerId) + "\"";
}
xml += " reportGroup=\"" + SecurityElement.Escape(reportGroup) + "\">";
if (litleTxnIdSet) xml += "\r\n<litleTxnId>" + litleTxnIdField + "</litleTxnId>";
xml += "\r\n<orderId>" + orderId + "</orderId>";
xml += "\r\n<amount>" + amount + "</amount>";
if (secondaryAmountSet) xml += "\r\n<secondaryAmount>" + secondaryAmountField + "</secondaryAmount>";
if (surchargeAmountSet) xml += "\r\n<surchargeAmount>" + surchargeAmountField + "</surchargeAmount>";
if (orderSource != null) xml += "\r\n<orderSource>" + orderSource.Serialize() + "</orderSource>";
if (customerInfo != null)
{
xml += "\r\n<customerInfo>" + customerInfo.Serialize() + "\r\n</customerInfo>";
}
if (billToAddress != null)
{
xml += "\r\n<billToAddress>" + billToAddress.Serialize() + "\r\n</billToAddress>";
}
if (shipToAddress != null)
{
xml += "\r\n<shipToAddress>" + shipToAddress.Serialize() + "\r\n</shipToAddress>";
}
if (card != null)
{
xml += "\r\n<card>" + card.Serialize() + "\r\n</card>";
}
else if (paypal != null)
{
xml += "\r\n<paypal>" + paypal.Serialize() + "\r\n</paypal>";
}
else if (token != null)
{
xml += "\r\n<token>" + token.Serialize() + "\r\n</token>";
}
else if (mpos != null)
{
xml += "\r\n<mpos>" + mpos.Serialize() + "</mpos>";
}
else if (paypage != null)
{
xml += "\r\n<paypage>" + paypage.Serialize() + "\r\n</paypage>";
}
else if (applepay != null)
{
xml += "\r\n<applepay>" + applepay.Serialize() + "\r\n</applepay>";
}
if (billMeLaterRequest != null)
{
xml += "\r\n<billMeLaterRequest>" + billMeLaterRequest.Serialize() + "\r\n</billMeLaterRequest>";
}
if (cardholderAuthentication != null)
{
xml += "\r\n<cardholderAuthentication>" + cardholderAuthentication.Serialize() + "\r\n</cardholderAuthentication>";
}
if (customBilling != null)
{
xml += "\r\n<customBilling>" + customBilling.Serialize() + "\r\n</customBilling>";
}
if (taxTypeSet)
{
xml += "\r\n<taxType>" + taxTypeField + "</taxType>";
}
if (enhancedData != null)
{
xml += "\r\n<enhancedData>" + enhancedData.Serialize() + "\r\n</enhancedData>";
}
if (processingInstructions != null)
{
xml += "\r\n<processingInstructions>" + processingInstructions.Serialize() + "\r\n</processingInstructions>";
}
if (pos != null)
{
xml += "\r\n<pos>" + pos.Serialize() + "\r\n</pos>";
}
if (payPalOrderCompleteSet) xml += "\r\n<payPalOrderCompleteSet>" + payPalOrderCompleteField.ToString().ToLower() + "</payPalOrderCompleteSet>";
if (payPalNotes != null) xml += "\r\n<payPalNotes>" + SecurityElement.Escape(payPalNotes) + "</payPalNotes>";
if (amexAggregatorData != null)
{
xml += "\r\n<amexAggregatorData>" + amexAggregatorData.Serialize() + "\r\n</amexAggregatorData>";
}
if (allowPartialAuthSet)
{
xml += "\r\n<allowPartialAuth>" + allowPartialAuthField.ToString().ToLower() + "</allowPartialAuth>";
}
if (healthcareIIAS != null)
{
xml += "\r\n<healthcareIIAS>" + healthcareIIAS.Serialize() + "\r\n</healthcareIIAS>";
}
if (filtering != null)
{
xml += "\r\n<filtering>" + filtering.Serialize() + "\r\n</filtering>";
}
if (merchantData != null)
{
xml += "\r\n<merchantData>" + merchantData.Serialize() + "\r\n</merchantData>";
}
if (recyclingRequest != null)
{
xml += "\r\n<recyclingRequest>" + recyclingRequest.Serialize() + "\r\n</recyclingRequest>";
}
if (fraudFilterOverrideSet) xml += "\r\n<fraudFilterOverride>" + fraudFilterOverrideField.ToString().ToLower() + "</fraudFilterOverride>";
if (recurringRequest != null)
{
xml += "\r\n<recurringRequest>" + recurringRequest.Serialize() + "\r\n</recurringRequest>";
}
if (litleInternalRecurringRequest != null)
{
xml += "\r\n<litleInternalRecurringRequest>" + litleInternalRecurringRequest.Serialize() + "\r\n</litleInternalRecurringRequest>";
}
if (debtRepaymentSet) xml += "\r\n<debtRepayment>" + debtRepayment.ToString().ToLower() + "</debtRepayment>";
if (advancedFraudChecks != null) xml += "\r\n<advancedFraudChecks>" + advancedFraudChecks.Serialize() + "\r\n</advancedFraudChecks>";
if (wallet != null)
{
xml += "\r\n<wallet>" + wallet.Serialize() + "\r\n</wallet>";
}
if (processingTypeSet)
{
xml += "\r\n<processingType>" + processingType + "</processingType>";
}
if (originalNetworkTxnSet)
{
xml += "\r\n<originalNetworkTransactionId>" + originalNetworkTransactionId + "</originalNetworkTransactionId>";
}
if (originalTxnAmountSet)
{
xml += "\r\n<originalTransactionAmount>" + originalTransactionAmount + "</originalTransactionAmount>";
}
xml += "\r\n</sale>";
return xml;
}
public void testSale() { sale sale = new sale(); sale.orderId = "12344"; sale.amount = 106; sale.orderSource = orderSourceType.ecommerce; cardType card = new cardType(); card.type = methodOfPaymentTypeEnum.VI; card.number = "4100000000000002"; card.expDate = "1210"; sale.card = card; batchRequest.addSale(sale); Assert.AreEqual(1, batchRequest.getNumSale()); Assert.AreEqual(sale.amount, batchRequest.getSumOfSale()); mockLitleFile.Verify(litleFile => litleFile.createRandomFile(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<String>(), mockLitleTime.Object)); mockLitleFile.Verify(litleFile => litleFile.AppendLineToFile(mockFilePath, sale.Serialize())); }